home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 1 / csmp-v1-194.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  122.0 KB  |  2,632 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Tue, 20 Oct 92       Volume 1 : Issue 194
  2.  
  3. Today's Topics:
  4.  
  5.     NON-QUICKDRAW GAMES
  6.  
  7.  
  8.  
  9. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  10.  
  11. The digest is a collection of article threads from the internet newsgroup
  12. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  13. regularly and want an archive of the discussions.  If you don't know what a
  14. newsgroup is, you probably don't have access to it.  Ask your systems
  15. administrator(s) for details.  (This means you can't post questions to the
  16. digest.)
  17.  
  18. Each issue of the digest contains one or more sets of articles (called
  19. threads), with each set corresponding to a 'discussion' of a particular
  20. subject.  The articles are not edited; all articles included in this digest
  21. are in their original posted form (as received by our news server at
  22. cs.uoregon.edu).  Article threads are not added to the digest until the last
  23. article added to the thread is at least one month old (this is to ensure that
  24. the thread is dead before adding it to the digest).  Article threads that
  25. consist of only one message are generally not included in the digest.
  26.  
  27. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  28. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  29. file /pub/mac/csmp-digest/README before downloading any files.  The most
  30. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  31. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  32. archive has a mail server; send a message with the text '$MACarch help' (no
  33. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  34.  
  35. The digest is also available via email.  Just send a note saying that you
  36. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  37. automatically receive each new issue as it is created.  Sorry, back issues
  38. are not available through the mailing list.
  39.  
  40. Send administrative mail to mkelly@cs.uoregon.edu.
  41.  
  42.  
  43. -------------------------------------------------------
  44.  
  45. From: deadman@garnet.berkeley.edu (Ben Haller)
  46. Subject: NON-QUICKDRAW GAMES
  47. Date: 2 Sep 92 23:53:14 GMT
  48. Organization: Stick Software
  49.  
  50. <I am crossposting this question, which arose in comp.sys.mac.games,
  51.  to comp.sys.mac.programmer since it seems appropriate.  I don't
  52.  read comp.sys.mac.programmer, so followups that I might want to
  53.  see / reply to, please keep in comp.sys.mac.games as well...>
  54.  
  55. In article <josteisv.2@dhhalden.no> josteisv@dhhalden.no
  56.   (JOSTEIN SVENDSEN) writes:
  57. >In article <17loj6INN7mb@agate.berkeley.edu> deadman@garnet.berkeley.edu
  58. >  (Ben Haller) (me) writes:
  59.  
  60. >>  The posting you saw was probably mine.  This is correct, many (most?)
  61. >>fast-action games for the Mac do not use QuickDraw.  Certainly I would
  62. >>never even attempt to write a fast-action game using QuickDraw.  The
  63. >>"other method" that is used is to write directly to the memory that
  64. >>represents the screen, with custom assembly code that results in faster
  65. >>drawing than QuickDraw is able to achieve.
  66.  
  67. >   Can you please give me some hints/tips on how to learn the skills 
  68. >neccessary to program fast-action games for the Mac?
  69. >- e.g. books, sources, programming languages etc.
  70.  
  71.   Well.  This topic has been covered many times on comp.sys.mac.programmer,
  72. and a (partial, at least) answer is in UMPG, the UseNet Macintosh
  73. Programmer's Guide, the ordering details of which can be found in the
  74. c.s.m.p. FAQ file.  But, since I'm in a good mood, I'll go over it briefly.
  75.  Books: UMPG has stuff, as mentioned above.  Inside Macintosh has all the
  76. actual technical details you need (if you include the tech notes, the 32
  77. Bit QuickDraw documentation, etc.), although putting the pieces together
  78. can be difficult, as usual with IM.  The latest (is it still the latest?)
  79. d e v e l o p magazine (available from Apple or APDA somehow, I believe)
  80. has quite a good article on direct to screen video, that's a very good
  81. source.  It has been mentioned in many other places, in varying levels of
  82. detail, but these three sources seem easy to find and relatively helpful.
  83.   Sources.  The only source code I know of that uses direct to screen video
  84. in a significant way is Juri Munki's (sp?) VectorKit code, which is now
  85. publicly available from some FTP site which he just told me, but which I
  86. forgot to save.  Someone else can surely produce the FTP site if there is
  87. demand.  There may be source available for other things that I am not aware
  88. of.  Source to my games (Solarian II, Lunatic Fringe) is not available no
  89. matter how much you beg, so please don't try.
  90.   Programming languages.  Think C is usually best for small projects,
  91. games, trivial things.  MPW C or C++ is better for projects being worked on
  92. by several people.  You may want to still use Think C, but use MPW to
  93. project your source files for version control, etc.
  94.   The actual code is really not very hard.  You get the base address of the
  95. monitor from the GDevice record of the monitor (see IM 5, GDevices), or by
  96. calling GetPixBaseAddr (but beware, old versions of that trap returned 0 in
  97. at least some cases).  You synch to the monitor by installing a VBL task
  98. with SlotVInstall (VInstall only synchs you to the monitor on the
  99. non-color-QuickDraw machines), getting the slot number from the AuxDevRec
  100. or some darn thing, which you get indirectly from the GDevice record (this
  101. is vague, I know, I could dig up details if needed).  You change pixels by
  102. simply writing to the memory off of the base address of the screen (beware,
  103. you may be in 24-bit mode and you may need to be in 32-bit mode, call
  104. SwapMMUMode to switch modes).  You may or may not want to notify the system
  105. that you have changed the pixels (PixMapChanged, or PixelsChanged, or some
  106. such trap - basically makes the GC card slightly less crash-prone than it
  107. otherwise is...)  Don't write outside of the actual screen space, leave the
  108. machine in the memory mode is was in when you're done, etc. and you'll be
  109. fine.  Did I forget anything?
  110.   I'd be glad to help anybody who needs it through e-mail, but remember,
  111. if your question is general at all, others would probably appreciate
  112. seeing the question and answer on the net, so you may want to keep
  113. discussion there.  Please respect the request about continuing the
  114. crossposting to both groups (c.s.m.p. and c.s.m.g.) since I do think it
  115. is relevant to both groups...
  116.  
  117. - -Ben Haller (deadman@garnet.berkeley.edu)
  118.  
  119. +++++++++++++++++++++++++++
  120.  
  121. From: mkelly@sisters.cs.uoregon.edu (Michael A. Kelly)
  122. Organization: University of Oregon Computer and Information Sciences Dept.
  123. Date: Thu, 3 Sep 1992 00:35:08 GMT
  124.  
  125.  
  126. Some sample code for drawing directly to video memory can be found in the
  127. comp.sys.mac.programmer FAQ, which was posted Tuesday to c.s.m.p. and
  128. news.answers.  It implements the basics, but for a real game you'll have
  129. to check into installing a VBL task and notifying the system of changes
  130. (using ShieldCursor, etc.).
  131.  
  132. So, Juri, where is this VectorKit code Ben mentioned?
  133.  
  134. Mike.
  135. - -- 
  136. _____________________________________________________________________________
  137. Michael A. Kelly                                         University of Oregon
  138. mkelly@cs.uoregon.edu                             Computer Science Department
  139. _____________________________________________________________________________
  140.  
  141. +++++++++++++++++++++++++++
  142.  
  143. From: jholt@adobe.com (joe holt)
  144. Organization: Adobe Systems Inc.
  145. Date: Thu, 3 Sep 1992 21:28:02 GMT
  146.  
  147. This is a fun subject, and I'd like to help spread the religion. Let me add
  148. a few bits:
  149.  
  150. To begin, insert all of the reasons *not* to draw directly to the screen.
  151. Would someone like to enumerate them? My favorite is that this can cause the
  152. GC card to crash. As if it needed my help. :-)
  153.  
  154. Personally, it bothers me to hear people cry about how dangerous it is to
  155. bypass QuickDraw, as if it's a matter of personal safety (you'll go blind).
  156. Most likely these people have never done it, or at least not to the extent
  157. that you do when really writing a game (or other application--did you know
  158. that ATM draws straight to the screen?). It can be scary as you're learning,
  159. because there are a few gotchas. Having done it, however, you realize that
  160. the entire strategy is easy to understand. All of the techniques are old old
  161. old game programmer tricks--there is nothing proprietary about them. What's
  162. new is the way they're used on the Mac, and especially the way you get around
  163. some of the Mac's video quirks.
  164.  
  165. It may not be obvious to everyone that the Mac's video screen is memory-
  166. mapped. That means that the pixels on the screen are also memory locations in
  167. RAM. By writing values into this RAM, you're also playing with pixels on the
  168. screen. This memory is real RAM: you can read the values back that you put in,
  169. and the computer can use it just like any other kind of RAM. In fact, you can
  170. even put programs in the video RAM. Of course, the screen would look like
  171. garbage, but what the hey, it'd be fun. (This used to be a copy protection
  172. technique on the Apple II--put code in the text video RAM. As soon as you drop
  173. into the monitor to hack the code, it scrolls off the screen). Actually,
  174. more interesting would be to put a program's variables in video RAM, and
  175. watch the colors change as the program ran. Now there's an INIT waiting to be
  176. written.
  177.  
  178. Anyway, so the first question is, where in RAM is the screen?
  179.  
  180. This turns out to be an easy thing to find out, although the method is
  181. different for Color QuickDraw and non-Color QuickDraw machines. So, the very
  182. first thing you need to do is call SysEnvirons() to find out if the machine
  183. has Color QuickDraw:
  184.  
  185.     SysEnvRec This_mac;
  186.  
  187.     SysEnvirons( 1, &This_mac );
  188.  
  189. Now you can get the base address like this:
  190.  
  191.     Ptr base_address;
  192.  
  193.     if ( This_mac.hasColorQD ) {
  194.         GDHandle the_monitor;
  195.  
  196.         the_monitor = GetMainDevice();
  197.         base_address = (**(**the_monitor).gdPMap).baseAddr;
  198.     }
  199.     else base_address = ScrnBase; /* low-memory global long at 0x824 */
  200.  
  201. A few things to mention right away. The recommended way to get a GDevice's
  202. base address is slightly different under System 7, but the above will work.
  203. Also, this will just give you the base address of the monitor with the menu
  204. bar on it. This will make those lucky few with multiple monitors angry if
  205. their other monitor is the one they want to play the game on. I'm also
  206. glossing over things like #include files and such.
  207.  
  208. What happens if you actually use this pointer and stick something there? Try
  209. this:
  210.  
  211.     int i;
  212.     Ptr p;
  213.  
  214.     for ( p = base_address, i = 50; i; --i )
  215.         *p++ = 0xAA;
  216.  
  217.     while ( !Button() );    /* wait for mouse click */
  218.     while ( Button() );
  219.  
  220. Did anything happen? If your monitor is in black and white, you probably got
  221. a line of alternating pixels across the very top line of the menu bar. If your
  222. monitor is in color, that line is shorter and probably made up of colored pixels.
  223. Rerun this at different monitor depths.
  224.  
  225. Did your Mac crash instead? Oops. Here's the first gotcha: some video cards,
  226. mostly the newer ones with millions of colors, need to be addressed in 32-bit
  227. mode. If you don't switch to 32-bit addressing before reading or writing into
  228. video RAM, you'll either get an ADDRESS ERROR or clobber other parts of memory
  229. with dire results. The reasons are really arcane and I'll be happy to explain
  230. them, but for now this info will just get in the way of the real fun that
  231. we're having (we are having fun, aren't we?). The little loop above would turn
  232. into this:
  233.  
  234.     int i;
  235.     Ptr p;
  236.     char old_MMUMode;
  237.  
  238.     if ( This_mac.hasColorQD ) {
  239.         old_MMUMode = true32b;
  240.         SwapMMUMode( &old_MMUMode );
  241.     }
  242.  
  243.     for ( p = base_addresss, i = 50; i; --i )
  244.         *p++ = 0xAA;
  245.  
  246.     if ( This_mac.hasColorQD )
  247.         SwapMMUMode( &old_MMUMode );
  248.  
  249. You see, what you have to do is set the Mac to 32-bit addressing and save the
  250. previous addressing mode, do your screen stuff, then set it back to the
  251. previous state. While in 32-bit addressing mode, you shouldn't make any ROM
  252. calls (mostly) or dereference handles and the like. The rule-of-thumb is to
  253. get back out of 32-bit addressing as soon as you can. Of course, if you have
  254. System 7 and your Mac is already in 32-bit addressing mode, the above code
  255. will work but the SwapMMUMode()'s are unnecessary. Same is true if the video
  256. card doesn't need 32-bit addressing. To do it right, you really should check
  257. all of these things.
  258.  
  259. You have just drawn directly to the screen. Hurrah!
  260.  
  261. As Ben mentioned, there are good sources for this kind of thing, although not
  262. everyone gets  d e v e l o p  magazine. If there is sufficient interest, we
  263. should all pitch in and turn this into a real thread. Things to cover include:
  264.  
  265.   1. setting up a vbl task
  266.   2. uses and abuses of off-screen buffers
  267.   3. clut animation
  268.   4. protecting your screen real estate
  269.   5. masking techniques
  270.   6. assembly language optimizations
  271.   7. <add yours here>
  272.  
  273. Let's see how far our collective wisdom can take us...
  274.  
  275. /joe
  276.  
  277.  
  278. +++++++++++++++++++++++++++
  279.  
  280. From: kw27+@andrew.cmu.edu (Kevin R. Walker)
  281. Date: 4 Sep 92 05:16:50 GMT
  282. Organization: Freshman, MCS general, Carnegie Mellon, Pittsburgh, PA
  283.  
  284. I think that a continuing thread on the non-QD graphics would be great.
  285. (IMHO)
  286.  
  287. Anyone with knowledge, please contribute what you are willing - and thanks
  288. to joe holt for his help.
  289.  
  290. Thanks,
  291. Kip
  292. - ----------
  293. Kip Walker
  294.  
  295. kw27+@andrew.cmu.edu
  296. kwalker+@cmu.edu
  297.  
  298. +++++++++++++++++++++++++++
  299.  
  300. From: mhall@occs.cs.oberlin.edu (Matthew Hall)
  301. Date: 6 Sep 92 18:55:23 GMT
  302. Organization: Oberlin College Computer Science
  303.  
  304.  
  305. Thank you for the information about drawing directly to the screen-
  306. now the next question.
  307. In 16 or 32 bit color, it's easy to draw the exact colors you want on
  308. screen just by filling in the RGBColors.  However- in 8 or 4 bit mode,
  309. you have to deal with palettes.  First of all, how do you assign a
  310. palette or color table to the screen.  You could just change the
  311. GDevices pmtable, but would that change the devices actual CLUT?  And
  312. if you set the colors by means of a palette, how do you get the
  313. correct indicies to write?  Conceivably, many machines might not be
  314. running the system software to support pmTolerant+pmExplicit, right?
  315. The drawing to screen stuff I can implement - but if someone could
  316. answer how to draw in an indexed color environment, I would really
  317. appreciate it.
  318.  
  319. Thank you-
  320. - -matt hall
  321.  
  322. - --
  323.  
  324.  
  325. - -------------------------------------------------------------------------------
  326. Matt Hall.    mhall@occs.cs.edu  OR  SMH9666@OBERLIN.BITNET
  327.               (216)-775-5805 (That's a Cleveland Area code. Lucky Me)
  328.  
  329. "If a man comes up to you and says:
  330.     'A dog just carried away your ear.'
  331. Do you run after the dog, or search first for your ear?" - Moon over Morocco
  332.   
  333.  
  334. +++++++++++++++++++++++++++
  335.  
  336. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  337. Date: 7 Sep 92 07:09:36 GMT
  338. Organization: Kalamazoo College
  339.  
  340. mhall@occs.cs.oberlin.edu (Matthew Hall) writes:
  341. >
  342. >First of all, how do you assign a
  343. >palette or color table to the screen.  You could just change the
  344. >GDevices pmtable, but would that change the devices actual CLUT?
  345.  
  346. Hiss, snarl!  This is Wrong with a capital W.  There's an off chance
  347. that it might work, but IM specifically warns you _never_ to directly
  348. change a system GDevice record.
  349.  
  350. >And
  351. >if you set the colors by means of a palette, how do you get the
  352. >correct indicies to write?  Conceivably, many machines might not be
  353. >running the system software to support pmTolerant+pmExplicit, right?
  354.  
  355. pmTolerant and pmExplicit usages have been around since Color QuickDraw
  356. was first put into a Mac.  Actually, you'll probably want
  357. pmAnimated+pmExplicit if you ever want to change colors, say for a fade
  358. to black.  But they work on every CQD Mac, and they're as compatible as
  359. you can get.  :-)
  360. - -- 
  361.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  362.  I suppose ya don't think I was run over by a streetcar!
  363.  
  364. +++++++++++++++++++++++++++
  365.  
  366. From: johnsd2@vccnw06.its.rpi.edu (Daniel Norman Johnson)
  367. Date: 7 Sep 92 13:17:52 GMT
  368. Organization: Rensselaer Polytechnic Institute, Troy, NY.
  369.  
  370. In article <1992Sep7.070936.3921@hobbes.kzoo.edu>, k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  371. [deletia- don't touch that GDevice]
  372. |> 
  373. |> >And
  374. |> >if you set the colors by means of a palette, how do you get the
  375. |> >correct indicies to write?  Conceivably, many machines might not be
  376. |> >running the system software to support pmTolerant+pmExplicit, right?
  377. |> 
  378. |> pmTolerant and pmExplicit usages have been around since Color QuickDraw
  379. |> was first put into a Mac.  Actually, you'll probably want
  380. |> pmAnimated+pmExplicit if you ever want to change colors, say for a fade
  381. |> to black.  But they work on every CQD Mac, and they're as compatible as
  382. |> you can get.  :-)
  383.  
  384. Um, I dont quite see why you need to use pmExplicit in either case... wouldn't
  385. just pmAnimated or pmTolerant do the job all by itself? I wont let u change
  386. teh values of white or black, but then I didn't think pmAnimate+pmExplicit
  387. will do that either.. will it?
  388.  
  389. Or am I missing something important here?
  390. - -- 
  391.             - Dan Johnson
  392. And God said "Jeeze, this is dull"... and it *WAS* dull. Genesis 0:0
  393.  
  394. These opinions have had all identifiying marks removed, and are untraceable.
  395. You'll never know whose they are.
  396.  
  397. +++++++++++++++++++++++++++
  398.  
  399. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  400. Date: 7 Sep 92 14:35:09 GMT
  401. Organization: Kalamazoo College
  402.  
  403. johnsd2@rpi.edu writes:
  404. >k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  405. >|> pmTolerant and pmExplicit usages have been around since Color QuickDraw
  406. >|> was first put into a Mac.  Actually, you'll probably want
  407. >|> pmAnimated+pmExplicit if you ever want to change colors, say for a fade
  408. >|> to black.
  409. >
  410. >Um, I dont quite see why you need to use pmExplicit in either case... wouldn't
  411. >just pmAnimated or pmTolerant do the job all by itself?
  412.  
  413. They will...but you don't know where the color will end up.  If you want
  414. palette entry #17 to be represented by color table entry #17 on the
  415. screen, use pmExplicit.
  416.  
  417. Otherwise, when you want to write the color represented by palette entry
  418. #17 to the screen, it could be anywhere in the color table, and you'll
  419. have to do nasty stuff like calling PmForeColor(), checking
  420. theCGrafPort.fgColor, and restoring the original foreground color.  Ick.
  421.  
  422.  
  423. Anyway, I take back what I said about "since CQD was first put into a
  424. Mac."  Any of the four usages by itself is OK with any Mac;
  425. pmTolerant+pmExplicit and pmAnimated+pmExplicit were apparently added
  426. with 32-bit QD.  Sorry.  I should read my IM V more often before
  427. making blanket statements like that.  (But it's hard because all the
  428. pages in the Palette Manager and Sound Manager chapters have come
  429. free of the binding.)
  430. - -- 
  431.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  432.  "I may not understand what you say, but I'll defend to your death
  433.   my right to deny it."                 - Albert, from 'Outrageously Pogo'
  434.  
  435. +++++++++++++++++++++++++++
  436.  
  437. From: russotto@eng.umd.edu (Matthew T. Russotto)
  438. Date: Mon, 07 Sep 92 16:51:14 GMT
  439. Organization: College of Engineering, University of Maryland, College Park
  440.  
  441. In article <MHALL.92Sep6135523@occs.cs.oberlin.edu> mhall@occs.cs.oberlin.edu (Matthew Hall) writes:
  442. >
  443. >Thank you for the information about drawing directly to the screen-
  444. >now the next question.
  445. >In 16 or 32 bit color, it's easy to draw the exact colors you want on
  446. >screen just by filling in the RGBColors.  However- in 8 or 4 bit mode,
  447. >you have to deal with palettes.  First of all, how do you assign a
  448. >palette or color table to the screen.
  449. Palette:  Use the Palette Manager to assign a palette to your window,
  450. and call ActivatePalette.  Use pmTolerant entries with a tolerance of
  451. $0000.
  452.  
  453. Color Table:  SetEntries.  This is rather unfriendly to any other
  454. programs, running, and when used in index mode generates ugly
  455. artifacts during the switch, at least on the Apple TFB cards.
  456.  
  457. >You could just change the
  458. >GDevices pmtable, but would that change the devices actual CLUT?
  459. No, that would just make a mess on your screen.
  460.  
  461. > And
  462. >if you set the colors by means of a palette, how do you get the
  463. >correct indicies to write?  Conceivably, many machines might not be
  464. >running the system software to support pmTolerant+pmExplicit, right?
  465.  
  466. You use PMForeColor and PMBackColor.  If you need to draw directly to
  467. the screen for speed or whatever, you can either make your own lookup
  468. table with Color2Index, and use it, use PMTolerant + PMExplicit if it
  469. is supported, or use SetEntries directly (and risk messing up other
  470. programs)
  471. - -- 
  472. Matthew T. Russotto    russotto@eng.umd.edu    russotto@wam.umd.edu
  473. Some news readers expect "Disclaimer:" here.
  474. Just say NO to police searches and seizures.  Make them use force.
  475. (not responsible for bodily harm resulting from following above advice)
  476.  
  477. +++++++++++++++++++++++++++
  478.  
  479. From: russotto@eng.umd.edu (Matthew T. Russotto)
  480. Date: 7 Sep 92 16:54:28 GMT
  481. Organization: College of Engineering, University of Maryland, College Park
  482.  
  483. In article <1992Sep7.070936.3921@hobbes.kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  484. >
  485. >pmTolerant and pmExplicit usages have been around since Color QuickDraw
  486. >was first put into a Mac.  Actually, you'll probably want
  487. >pmAnimated+pmExplicit if you ever want to change colors, say for a fade
  488. >to black.  But they work on every CQD Mac, and they're as compatible as
  489. >you can get.  :-)
  490.  
  491. Nope.  PMTolerant+PmExplicit (for getting the right colors in the
  492. right place in the color table) was introduced with 32 bit Quickdraw
  493. (version 1.2, I believe)
  494.  
  495. - -- 
  496. Matthew T. Russotto    russotto@eng.umd.edu    russotto@wam.umd.edu
  497. Some news readers expect "Disclaimer:" here.
  498. Just say NO to police searches and seizures.  Make them use force.
  499. (not responsible for bodily harm resulting from following above advice)
  500.  
  501. +++++++++++++++++++++++++++
  502.  
  503. From: jmunkki@vipunen.hut.fi (Juri Munkki)
  504. Date: 8 Sep 92 17:30:31 GMT
  505. Organization: Helsinki University of Technology
  506.  
  507. In article <1992Sep3.003508.26714@cs.uoregon.edu> mkelly@sisters.cs.uoregon.edu (Michael A. Kelly) writes:
  508. >So, Juri, where is this VectorKit code Ben mentioned?
  509.  
  510. Actually, the package that I put on anonymous ftp has the full source
  511. code for the STORM/ARASHI project. It has the sound kit, game code,
  512. some sample programs and the animation kit and documentation for all
  513. of the above. The code still isn't finished, but I have nop plans or
  514. time to do anything with it, so you'll have to do with what's there
  515. right now. Remember to use binary mode for the downloads!
  516.  
  517. I might have missed a few source files, so let me know if anything is
  518. missing.
  519.  
  520. The ftp site is ics.uci.edu. Look for arashi.cpt.bin or something like
  521. that in the mac directory tree. My connection to ics.uci.edu is down right
  522. now, so I can't look where it is exactly. As far as I know, the code should
  523. be also soon available somewhere on Applelink. I have no problems with
  524. redistribution, so if want to put it somewhere else, please drop me a note
  525. even though you don't need my permission.
  526.  
  527. It's very easy to write new vector animation based games with this kit.
  528. You have to have good C programming experience, but assembler is not required.
  529.  
  530. You need Think C 5.0 or later and Compact Pro to open the archive.
  531.  
  532. - -- 
  533.   Juri Munkki                           Windsurf: fast sailing
  534.  jmunkki@hut.fi                          Macintosh: fast software
  535.  
  536. +++++++++++++++++++++++++++
  537.  
  538. From: deadman@garnet.berkeley.edu (Ben Haller)
  539. Date: 8 Sep 1992 22:42:11 GMT
  540. Organization: Stick Software
  541.  
  542. In article <MHALL.92Sep6135523@occs.cs.oberlin.edu>
  543.   mhall@occs.cs.oberlin.edu (Matthew Hall) writes:
  544. >you have to deal with palettes.  First of all, how do you assign a
  545. >palette or color table to the screen.  You could just change the
  546. >GDevices pmtable, but would that change the devices actual CLUT?  And
  547. >if you set the colors by means of a palette, how do you get the
  548. >correct indicies to write?  Conceivably, many machines might not be
  549. >running the system software to support pmTolerant+pmExplicit, right?
  550. >The drawing to screen stuff I can implement - but if someone could
  551. >answer how to draw in an indexed color environment, I would really
  552. >appreciate it.
  553.  
  554.   As several people have already indicated, the two basic methods
  555. are either using the Palette Wrecker (oh, did I say wrecker?  I meant
  556. manager) or using SetEntries.  The thing I want to address is this,
  557. in my mind unwarranted, bias towards the Palette Wrecker (there, I
  558. mistyped it again!)
  559.   If you use it, in the best of all possible worlds, when your application
  560. get context-switched in your palette will be swapped back in, using the
  561. best possible slots in the CLUT taking into consideration the colors
  562. everybody else is using, etc. etc.  This is hogwash - it never happens.
  563. In my experience using the palette manager means the screen does CLUT
  564. flashes that are even more distracting than they would usually be (i.e.
  565. it will often flash *several times*), you end up with a pretty crappy CLUT
  566. that in no way avoids frequently-used colors, and the other applications
  567. in the system are often permanantly fucked up and don't redraw correctly
  568. from then on.  It just isn't worth it, folks.  Nobody else uses the Palette
  569. Wrecker, and so all of the much-touted benefits simply aren't there (lack
  570. of entry conflicts with other apps, etc.)  And it has a lot of drawbacks,
  571. not the least being that's it's slow, it increases your code size, it
  572. looks worse, and it's (in my opinion) meither as aesthetically pleasing
  573. nor as compatable as just saving & setting the CLUT (or part of the CLUT)
  574. on resume events and restoring the parts you changed on suspend events.
  575.   Also, if you're using direct-to-screen as almost everyone does - in a
  576. pixel-oriented paint program or in a video game - then you'll want the
  577. whole CLUT to yourself, in which case the Palette Wrecker (even if it
  578. worked) provides no benefits and all the drawbacks.
  579.   Get real.  Just because Apple says to use the Palette Wrecker doesn't
  580. mean you have to.  There is nothing wrong with SetEntries - at least
  581. nothing that the Wrecker fixes.  So why bother.
  582.   OK, I'm ready for the flames... :->
  583.  
  584. - -Ben Haller (deadman@garnet.berkeley.edu)
  585.  
  586. +++++++++++++++++++++++++++
  587.  
  588. From: johnsd2@lib104.its.rpi.edu (Daniel Norman Johnson)
  589. Date: 8 Sep 92 23:38:45 GMT
  590. Organization: Rensselaer Polytechnic Institute, Troy, NY.
  591.  
  592. In article <18ja83INNk53@agate.berkeley.edu>, deadman@garnet.berkeley.edu (Ben Haller) writes:
  593. |> In article <MHALL.92Sep6135523@occs.cs.oberlin.edu>
  594. |>   mhall@occs.cs.oberlin.edu (Matthew Hall) writes:
  595. |> >you have to deal with palettes.  First of all, how do you assign a
  596. |> >palette or color table to the screen.  You could just change the
  597. |> >GDevices pmtable, but would that change the devices actual CLUT?  And
  598. |> >if you set the colors by means of a palette, how do you get the
  599. |> >correct indicies to write?  Conceivably, many machines might not be
  600. |> >running the system software to support pmTolerant+pmExplicit, right?
  601. |> >The drawing to screen stuff I can implement - but if someone could
  602. |> >answer how to draw in an indexed color environment, I would really
  603. |> >appreciate it.
  604. |> 
  605. |>   As several people have already indicated, the two basic methods
  606. |> are either using the Palette Wrecker (oh, did I say wrecker?  I meant
  607. |> manager) or using SetEntries.  The thing I want to address is this,
  608. |> in my mind unwarranted, bias towards the Palette Wrecker (there, I
  609. |> mistyped it again!)
  610.  
  611. Dang.. ya gotta watch them typos, ya know :)
  612.  
  613. |>   If you use it, in the best of all possible worlds, when your application
  614. |> get context-switched in your palette will be swapped back in, using the
  615. |> best possible slots in the CLUT taking into consideration the colors
  616. |> everybody else is using, etc. etc.  This is hogwash - it never happens.
  617.  
  618. Granted. The Palette Manager does not care about which slots it
  619. uses. I don't see why you do.. is there some benefit to particular
  620. slots that I am not aware of? Id think that CLUT slot is pretty
  621. much like annother, unless u r XORing things... Of course, u could use
  622. pmExplicit colors to get specific indicies.
  623.  
  624. |> In my experience using the palette manager means the screen does CLUT
  625. |> flashes that are even more distracting than they would usually be (i.e.
  626. |> it will often flash *several times*),
  627.  
  628. I have never seen this myself. Can you give an example?
  629. [ie how can I make it happen?]
  630.  
  631. Also, I presume the technique you propound somehow gets the screen
  632. to redraw, with the new colors. Otherwise, you'd wind up with the
  633. usual my-background-is-in-briliant-yellow-and-turquoise-and-my-finder-
  634. icons-are-indecyperable syndrome. This bothers me much more than the
  635. "flash" the palette manager produces. And things only get weirder, since
  636. thigns that are redraw/exposed get draw right, but everything else
  637. is still mauve or something. yeck. :)
  638.  
  639. |> you end up with a pretty crappy CLUT
  640. |> that in no way avoids frequently-used colors, and the other applications
  641. |> in the system are often permanantly fucked up and don't redraw correctly
  642. |> from then on.
  643.  
  644. Can you give examples of when this happens too? It does not
  645. happen to the programs I have written that use palettes. Also,
  646. why dont they have the same prob with direct-clut-changes?
  647.  
  648. |>  It just isn't worth it, folks.  Nobody else uses the Palette
  649. |> Wrecker, and so all of the much-touted benefits simply aren't there (lack
  650. |> of entry conflicts with other apps, etc.)
  651.  
  652. Well, the-no-entry-conflicts thing works for apps that dont use ANY
  653. clut or palette mucking.. they are forced to redraw, and do so with
  654. the new colors. This is of course only in my experience, u have
  655. already said yours differs. It also works for other programs
  656. that use the palette manager, and it does no harm for those that
  657. don't, right?
  658.  
  659. |>  And it has a lot of drawbacks,
  660. |> not the least being that's it's slow,
  661.  
  662. granted.
  663.  
  664. |> it increases your code size,
  665.  
  666. how does it do this? U can have a palette in a pltt resources
  667. and not add ANY code, if u r using GetNewCWindow. You
  668. can grab palettes from resources with very little
  669. code. Even if you are assembling one on-the-fly, it doesn't seem
  670. to me like it takes nearly as much code to allocate, fill in,
  671. assign and activate a palette as it would to write code to make
  672. clut-manipulation work on multiple monitors,  on direct devices,
  673. on b&w machines, etc
  674.  
  675. By the way, Im talking about the more general case of
  676. drawing-w/-quickdraw-in-a-window, not just the direct screen drawing
  677. stuff and the take-over-teh-screen stuff, since you appear to be saying
  678. "never use teh Palette Wrecker, ever ever ever". I can see (now) why you
  679. would not want to do this if you are not using windows, quickdraw, etc.
  680. It would be most pointless, but slow anyway. :)
  681.  
  682. |> it
  683. |> looks worse, and it's (in my opinion) meither as aesthetically pleasing
  684. |> nor as compatable as just saving & setting the CLUT (or part of the CLUT)
  685. |> on resume events and restoring the parts you changed on suspend events.
  686.  
  687. Why do you say this? The palette manager should be able to completely
  688. change the clut to anything u want, 'cept u have to have black and white
  689. in the clut. Is that such a big difference?
  690.  
  691. Anyway, if u r gonna save and restore the clut, how do u force all other
  692. apps and such to redraw [in teh case where u r not taking over the
  693. whole screen], and of course also force teh desktop to redraw?
  694.  
  695. Also, why is the Palette Manager less compatible than CLUT stuff?
  696.  
  697. |>   Also, if you're using direct-to-screen as almost everyone does - in a
  698. |> pixel-oriented paint program or in a video game - then you'll want the
  699. |> whole CLUT to yourself, in which case the Palette Wrecker (even if it
  700. |> worked) provides no benefits and all the drawbacks.
  701.  
  702. Well, the Palette Manager takes care of multiple-monitor setups for you,
  703. and direct devices. I thot u'd have to special-case for that if
  704. u r using SetEntries. This doesn't matter if you are taking over the
  705. screen, but that drawing program ought to run in a window.
  706.  
  707. |>   Get real.
  708.  
  709. C'mon... I wanna get fake! :(
  710.  
  711. |>  Just because Apple says to use the Palette Wrecker doesn't
  712. |> mean you have to.  There is nothing wrong with SetEntries - at least
  713. |> nothing that the Wrecker fixes.  So why bother.
  714.  
  715. Well, the Palette Manager takes care of a bunch of details for you,
  716. which I have mentioned, and lets you share palette entries with other
  717. apps if you like (although this doens't work very well, in my option.
  718. Its that annoying restriction on the values tolerances can take.. you
  719. cant have small, non-zero tolerances. bleah) It also (in my experience,
  720. perhaps yours differs again) can allocate "unused" palette entries- IF
  721. other apps are using the palette manager. If they aren't, no harm (that
  722. I know of) done.
  723.  
  724. |>   OK, I'm ready for the flames... :->
  725.  
  726. I tried to be reasonable, and not flame. Mostly because
  727. I have the feeling that Im way, way out of my depth
  728. arguing with you. But what the hey. Now pardon me why
  729. I go dig up my asbestos underwear. I have a feeling
  730. my ignorance is about to be rudely exposed. :)
  731.  
  732. |> -Ben Haller (deadman@garnet.berkeley.edu)
  733.  
  734. - -- 
  735.             - Dan Johnson
  736. And God said "Jeeze, this is dull"... and it *WAS* dull. Genesis 0:0
  737.  
  738. These opinions have had all identifiying marks removed, and are untraceable.
  739. You'll never know whose they are.
  740.  
  741. +++++++++++++++++++++++++++
  742.  
  743. From: deadman@garnet.berkeley.edu (Ben Haller)
  744. Date: 9 Sep 92 17:13:19 GMT
  745. Organization: Stick Software
  746.  
  747. In article <#m4y9kn@rpi.edu> johnsd2@rpi.edu writes:
  748. >In article <18ja83INNk53@agate.berkeley.edu>,
  749. >  deadman@garnet.berkeley.edu (Ben Haller) writes:
  750. >|>   As several people have already indicated, the two basic methods
  751. >|> are either using the Palette Wrecker (oh, did I say wrecker?  I meant
  752. >|> manager) or using SetEntries.  The thing I want to address is this,
  753. >|> in my mind unwarranted, bias towards the Palette Wrecker (there, I
  754. >|> mistyped it again!)
  755. >Dang.. ya gotta watch them typos, ya know :)
  756. I just keep doing it, I don't know why...but then you seem to mistype
  757. "you" as "u" (not to mention "the" as "teh"...) :->
  758.  
  759. >|>   If you use it, in the best of all possible worlds, when your application
  760. >|> get context-switched in your palette will be swapped back in, using the
  761. >|> best possible slots in the CLUT taking into consideration the colors
  762. >|> everybody else is using, etc. etc.  This is hogwash - it never happens.
  763. >Granted. The Palette Manager does not care about which slots it
  764. >uses. I don't see why you do.. is there some benefit to particular
  765. >slots that I am not aware of? Id think that CLUT slot is pretty
  766. >much like annother, unless u r XORing things... Of course, u could use
  767. >pmExplicit colors to get specific indicies.
  768. No, the whole point of using the Palette Manager, as far as I can tell
  769. from Inside Mac, is that you will be compatable with other people, to
  770. reduce the amount of CLUT-flashing and such that goes on to a minimum.
  771. Well, not the whole point.  But most of the point.  When you ask for
  772. a certain shade of green, it is supposed to either say "oh, here's a
  773. green that's good enough, use it" or say "well, there's no green close
  774. enough, here's one that I just allocated into the CLUT using a slot nobody
  775. else's palette was using."  The first case works, but then you could've
  776. called Color2Index to find that out.  The second case does not work
  777. unless everybody else running is also using the Palette Manager (not
  778. bloody likely - what proportion of commercial apps do you suppose use
  779. the Palette Manager?)
  780.  
  781. >|> In my experience using the palette manager means the screen does CLUT
  782. >|> flashes that are even more distracting than they would usually be (i.e.
  783. >|> it will often flash *several times*),
  784. >I have never seen this myself. Can you give an example?
  785. >[ie how can I make it happen?]
  786. No, I can't.  I haven't used the Palette Manager in years.  Anybody want
  787. to give an example, or alternatively tell me I'm full of it?  I may
  788. be full of it, but this was my impression.
  789.   A point in your favor.
  790.  
  791. >Also, I presume the technique you propound somehow gets the screen
  792. >to redraw, with the new colors. Otherwise, you'd wind up with the
  793. >usual my-background-is-in-briliant-yellow-and-turquoise-and-my-finder-
  794. >icons-are-indecyperable syndrome. This bothers me much more than the
  795. >"flash" the palette manager produces. And things only get weirder, since
  796. >thigns that are redraw/exposed get draw right, but everything else
  797. >is still mauve or something. yeck. :)
  798. Mmm, you can force a refresh, but you would be quite right to point out
  799. that the Palette Manager can do a selective refresh on only the windows
  800. that requested color update refreshes, which is preferable.  A point in
  801. your favor.
  802.  
  803. >|> you end up with a pretty crappy CLUT
  804. >|> that in no way avoids frequently-used colors, and the other applications
  805. >|> in the system are often permanantly fucked up and don't redraw correctly
  806. >|> from then on.
  807. >Can you give examples of when this happens too? It does not
  808. >happen to the programs I have written that use palettes. Also,
  809. >why dont they have the same prob with direct-clut-changes?
  810. OK, here I think I'm on firm ground.  Applications that are written
  811. correctly using SetEntries install their CLUT on resume events and
  812. replace the CLUT that they overwrote on suspend events, and therefore
  813. applications that depend on having the system CLUT get the system CLUT.
  814.   Application that use the Palette Manager basically get ActivatePalette
  815. called for them when their window comes to front.  *But* - when another
  816. application that doesn't use the Palette Manager *or* SetEntries get
  817. brought to front, the environment is not restored.  The other applications
  818. palette stays in place, and the app that wanted the system palette is
  819. fucked (pardon the expression).
  820.   Now you could say "oh, well that application should have put in a palette
  821. that had the full system palette in it, and then everything would have
  822. worked."  But IMV-152 says "If the front window is an old-style window,
  823. or if it has no assigned palette, the Palette Manager establishes the color
  824. environment using a default palette.  For many simple application the
  825. default palette will suffice."  To me this implies that you are supposed
  826. to be more or less guaranteed the system palette unless you request
  827. something else.  It doesn't seem to work this way.
  828.   Any comments?  As I said, I haven't written an app using the Palette
  829. Wrecker (oops) in a long time, maybe Apple has fixed this sort of thing.
  830. But I seem to recall ResEdit still premanantly fucks up the color
  831. environment (it sort of flips the clut across the line y=x, for
  832. no apparent reason, which confuses the hell out of the Finder), and
  833. presumably it uses the Palette Wrecker.
  834.   Until further notice, I'll count a point for me...
  835.  
  836. >|>  It just isn't worth it, folks.  Nobody else uses the Palette
  837. >|> Wrecker, and so all of the much-touted benefits simply aren't there (lack
  838. >|> of entry conflicts with other apps, etc.)
  839. >Well, the-no-entry-conflicts thing works for apps that dont use ANY
  840. >clut or palette mucking.. they are forced to redraw, and do so with
  841. >the new colors. This is of course only in my experience, u have
  842. >already said yours differs. It also works for other programs
  843. >that use the palette manager, and it does no harm for those that
  844. >don't, right?
  845. See the discussion above, I believe it *does* harm apps that don't fiddle
  846. with the color environment in any way.
  847.  
  848. >|>  And it has a lot of drawbacks,
  849. >|> not the least being that's it's slow,
  850. >granted.
  851.  
  852. >|> it increases your code size,
  853. >how does it do this? U can have a palette in a pltt resources
  854. >and not add ANY code, if u r using GetNewCWindow. You
  855. >can grab palettes from resources with very little
  856. >code. Even if you are assembling one on-the-fly, it doesn't seem
  857. >to me like it takes nearly as much code to allocate, fill in,
  858. >assign and activate a palette as it would to write code to make
  859. >clut-manipulation work on multiple monitors,  on direct devices,
  860. >on b&w machines, etc
  861. OK, perhaps you are right on this.  Point for you.  I was thinking
  862. more of the type of CLUT code I tend to write (take over the screen),
  863. whereas you're talking more about QD-in-a-window.
  864.  
  865. >By the way, Im talking about the more general case of
  866. >drawing-w/-quickdraw-in-a-window, not just the direct screen drawing
  867. >stuff and the take-over-teh-screen stuff, since you appear to be saying
  868. >"never use teh Palette Wrecker, ever ever ever". I can see (now) why you
  869. >would not want to do this if you are not using windows, quickdraw, etc.
  870. >It would be most pointless, but slow anyway. :)
  871. Yes, I think I stated my case a little more broadly than I should have.
  872. In many cases the Palette Wrecker does save time & effort, and if it's
  873. a little buggy and annoying (a LITTLE?) well, maybe Apple will fix it
  874. someday.
  875.  
  876. >|> it
  877. >|> looks worse, and it's (in my opinion) meither as aesthetically pleasing
  878. >|> nor as compatable as just saving & setting the CLUT (or part of the CLUT)
  879. >|> on resume events and restoring the parts you changed on suspend events.
  880. >Why do you say this? The palette manager should be able to completely
  881. >change the clut to anything u want, 'cept u have to have black and white
  882. >in the clut. Is that such a big difference?
  883. I recall that when I tried to use the Palette Wrecker (so long ago) to
  884. do stuff, it did not, in fact, like being used to take over very much
  885. of the CLUT.  Everything would be fine until a dialog or something
  886. came up, and then my nice green would suddenly be replaced by an icky
  887. brown (which the dialog didn't even use!)  Of course, this happens with
  888. CLUT setting too, but hey, the Palette Wrecker is supposed to fix such
  889. problems.
  890.   BTW, anybody noticed the charming System 7 bug that when the Color Picker
  891. comes up, after you dismiss it it leaves the CLUT fucked up?  Charming.
  892. They haven't fixed that one yet, have they?
  893.  
  894. >Anyway, if u r gonna save and restore the clut, how do u force all other
  895. >apps and such to redraw [in teh case where u r not taking over the
  896. >whole screen], and of course also force teh desktop to redraw?
  897. Well, forcing a full refresh is easy, I could post the code if you
  898. really want it.  A few lines.  But only updating the windows that
  899. want a color refresh is not easy, and I conceded that point to you above.
  900.  
  901. >Also, why is the Palette Manager less compatible than CLUT stuff?
  902. The apps-that-use-the-system-palette problem described above.
  903.  
  904. >|>   Also, if you're using direct-to-screen as almost everyone does - in a
  905. >|> pixel-oriented paint program or in a video game - then you'll want the
  906. >|> whole CLUT to yourself, in which case the Palette Wrecker (even if it
  907. >|> worked) provides no benefits and all the drawbacks.
  908. >Well, the Palette Manager takes care of multiple-monitor setups for you,
  909. >and direct devices. I thot u'd have to special-case for that if
  910. >u r using SetEntries. This doesn't matter if you are taking over the
  911. >screen, but that drawing program ought to run in a window.
  912. Yes, but...suppose it's an 8-bit paint program, in my opinion it would
  913. be dumb to try to display on a 4-bit or less display, you just want to
  914. leave those monitor's CLUTs alone and paint your window with white on
  915. those monitors.  Which the Palette Wrecker won't do.  A loop that sets
  916. all CLUT-driven 8-bit active screen devices to your CLUT is what you
  917. really want in this case, so the PaletteWrecker does you little good.
  918.   Direct devices, etc. I tend to feel the same way - either they have
  919. enough colors that you can show the 8-bit image on them just doing
  920. matching with Color2Index (why is PmForeColor any better?) or you can't,
  921. in which case you're just going to fill with white.
  922.  
  923. >|>  Just because Apple says to use the Palette Wrecker doesn't
  924. >|> mean you have to.  There is nothing wrong with SetEntries - at least
  925. >|> nothing that the Wrecker fixes.  So why bother.
  926. >Well, the Palette Manager takes care of a bunch of details for you,
  927. >which I have mentioned, and lets you share palette entries with other
  928. >apps if you like (although this doens't work very well, in my option.
  929. >Its that annoying restriction on the values tolerances can take.. you
  930. >cant have small, non-zero tolerances. bleah) It also (in my experience,
  931. >perhaps yours differs again) can allocate "unused" palette entries- IF
  932. >other apps are using the palette manager. If they aren't, no harm (that
  933. >I know of) done.
  934. All discussed above.  You have a point, as I conceded, and I reduce my
  935. claim somewhat.
  936.  
  937. >|>   OK, I'm ready for the flames... :->
  938. >I tried to be reasonable, and not flame. Mostly because
  939. >I have the feeling that Im way, way out of my depth
  940. >arguing with you. But what the hey. Now pardon me why
  941. >I go dig up my asbestos underwear. I have a feeling
  942. >my ignorance is about to be rudely exposed. :)
  943.   You were very kind not to flame, given the unwise generality of my
  944. original declaration.  I hope this reply didn't seem too hot either, I
  945. think if it's a matter of one or the other of use being right I'd
  946. give the prize to you.  However, I still feel SetEntries is better when
  947. you're either taking over a monitor entirely, or when you want the whole
  948. CLUT to yourself guaranteed.
  949.   Sorry to waste bandwidth on stupid arguments, folks.  I was in a bad
  950. mood yesterday, and didn't phrase my argument as rationally as I might
  951. have...
  952.  
  953. - -Ben Haller (deadman@garnet.berkeley.edu)
  954.  
  955. +++++++++++++++++++++++++++
  956.  
  957. From: johnsd2@lib106.its.rpi.edu (Daniel Norman Johnson)
  958. Date: 9 Sep 92 21:15:31 GMT
  959. Organization: Rensselaer Polytechnic Institute, Troy, NY.
  960.  
  961. [note that I inserted blank lines all over the place, so I could
  962.  read this stuff]
  963.  
  964. In article <18lbbfINNsdp@agate.berkeley.edu>, deadman@garnet.berkeley.edu (Ben Haller) writes:
  965. |> In article <#m4y9kn@rpi.edu> johnsd2@rpi.edu writes:
  966. |> >In article <18ja83INNk53@agate.berkeley.edu>,
  967. |> >  deadman@garnet.berkeley.edu (Ben Haller) writes:
  968. |> >|>   As several people have already indicated, the two basic methods
  969. |> >|> are either using the Palette Wrecker (oh, did I say wrecker?  I meant
  970. |> >|> manager) or using SetEntries.  The thing I want to address is this,
  971. |> >|> in my mind unwarranted, bias towards the Palette Wrecker (there, I
  972. |> >|> mistyped it again!)
  973.  
  974. |> >Dang.. ya gotta watch them typos, ya know :)
  975.  
  976. |> I just keep doing it, I don't know why...but then you seem to mistype
  977. |> "you" as "u" (not to mention "the" as "teh"...) :->
  978.  
  979. Hmm... must be line noise. That's it, yeah... :)
  980.  
  981. [deletia- Palette Manager gives u best o' all possible worlds. Not. ]
  982. |> >Granted. The Palette Manager does not care about which slots it
  983. |> >uses. I don't see why you do.. is there some benefit to particular
  984. |> >slots that I am not aware of? Id think that CLUT slot is pretty
  985. |> >much like annother, unless u r XORing things... Of course, u could use
  986. |> >pmExplicit colors to get specific indicies.
  987.  
  988. |> No, the whole point of using the Palette Manager, as far as I can tell
  989. |> from Inside Mac, is that you will be compatable with other people, to
  990. |> reduce the amount of CLUT-flashing and such that goes on to a minimum.
  991. |> Well, not the whole point.  But most of the point.
  992.  
  993. Well, I would say it has a more important function- to be compatible
  994. with all sorts of wierd hardware, new system versions, etc. SetEntries
  995. and all that can be made compatible, of course, but that sounds
  996. like doing things the hard way.
  997.  
  998. |>  When you ask for
  999. |> a certain shade of green, it is supposed to either say "oh, here's a
  1000. |> green that's good enough, use it" or say "well, there's no green close
  1001. |> enough, here's one that I just allocated into the CLUT using a slot nobody
  1002. |> else's palette was using."  The first case works, but then you could've
  1003. |> called Color2Index to find that out.
  1004.  
  1005. Sure. But why bother? [actually, thats a bit of a silly
  1006. question. That's what your artile was about. :)]
  1007.  
  1008. |>  The second case does not work
  1009. |> unless everybody else running is also using the Palette Manager (not
  1010. |> bloody likely - what proportion of commercial apps do you suppose use
  1011. |> the Palette Manager?)
  1012.  
  1013. Id make that "anybody" not "everybody"; if we have 3 apps, A B and C [such
  1014. nice names], and A and B use the palette manager and C does not, then
  1015. A and B will avoid each others palettes (allegedly. You claim this
  1016. does not work; I have never tested it); Neither will avoid the
  1017. colors C is using (if any), but you are still deriving some benefit.
  1018. Ill get more into what happens to C later, since C is probably
  1019. the Finder. :)
  1020.  
  1021. |> >|> In my experience using the palette manager means the screen does CLUT
  1022. |> >|> flashes that are even more distracting than they would usually be (i.e.
  1023. |> >|> it will often flash *several times*),
  1024.  
  1025. |> >I have never seen this myself. Can you give an example?
  1026. |> >[ie how can I make it happen?]
  1027.  
  1028. |> No, I can't.  I haven't used the Palette Manager in years.  Anybody want
  1029. |> to give an example, or alternatively tell me I'm full of it?  I may
  1030. |> be full of it, but this was my impression.
  1031. |>   A point in your favor.
  1032.  
  1033. Yay! A Point! That's one! :)
  1034. I am also eagerly awaiting instructions on how to muck up the
  1035. Palette Manager this way. So if u email it to Ben Haller,
  1036. please email it to me too. Thanx.
  1037.  
  1038. |> >Also, I presume the technique you propound somehow gets the screen
  1039. |> >to redraw, with the new colors. Otherwise, you'd wind up with the
  1040. |> >usual my-background-is-in-briliant-yellow-and-turquoise-and-my-finder-
  1041. |> >icons-are-indecyperable syndrome. This bothers me much more than the
  1042. |> >"flash" the palette manager produces. And things only get weirder, since
  1043. |> >thigns that are redraw/exposed get draw right, but everything else
  1044. |> >is still mauve or something. yeck. :)
  1045.  
  1046. |> Mmm, you can force a refresh, but you would be quite right to point out
  1047. |> that the Palette Manager can do a selective refresh on only the windows
  1048. |> that requested color update refreshes, which is preferable.  A point in
  1049. |> your favor.
  1050.  
  1051. Thats 2 points! Im on a roll! Anyway,
  1052.  
  1053. Well, maybe *you* can force a refresh. I dont know how. And I have
  1054. seen a few comercial apps that dont know how either. Also, it seems
  1055. to me that most of the time wasted by the Palette Manager is spent
  1056. redrawing teh screen.. in this case do you not invoke a similar penalty
  1057. (although probably smaller... I think the PM is wasting more time than
  1058. just this)
  1059.  
  1060. |> >|> you end up with a pretty crappy CLUT
  1061. |> >|> that in no way avoids frequently-used colors, and the other applications
  1062. |> >|> in the system are often permanantly fucked up and don't redraw correctly
  1063. |> >|> from then on.
  1064.  
  1065. |> >Can you give examples of when this happens too? It does not
  1066. |> >happen to the programs I have written that use palettes. Also,
  1067. |> >why dont they have the same prob with direct-clut-changes?
  1068.  
  1069. |> OK, here I think I'm on firm ground.  Applications that are written
  1070. |> correctly using SetEntries install their CLUT on resume events and
  1071. |> replace the CLUT that they overwrote on suspend events, and therefore
  1072. |> applications that depend on having the system CLUT get the system CLUT.
  1073.  
  1074. I talk about the question of apps-w/-no-clut-or-palette below. A Lot.
  1075. Just one other thing:
  1076.  
  1077. Doesn't this depend on the order in which these events happen? Is
  1078. it garaounteed that suspends come before resumes? If not, then
  1079. you could wind up "saving" the wrong CLUT.
  1080.  
  1081. Also, what if you dont want all the colors?
  1082.  
  1083. |>   Application that use the Palette Manager basically get ActivatePalette
  1084. |> called for them when their window comes to front.  *But* - when another
  1085. |> application that doesn't use the Palette Manager *or* SetEntries get
  1086. |> brought to front, the environment is not restored.  The other applications
  1087. |> palette stays in place, and the app that wanted the system palette is
  1088. |> fucked (pardon the expression).
  1089.  
  1090. Yes, it is.
  1091.  
  1092. |>   Now you could say "oh, well that application should have put in a palette
  1093. |> that had the full system palette in it, and then everything would have
  1094. |> worked."
  1095.  
  1096. Yuck. This is not a good idea, the palette will be loaded backwards or
  1097. something.. not in the "standard" order. This slows down copybits!
  1098.  
  1099. |>  But IMV-152 says "If the front window is an old-style window,
  1100. |> or if it has no assigned palette, the Palette Manager establishes the color
  1101. |> environment using a default palette.  For many simple application the
  1102. |> default palette will suffice."  To me this implies that you are supposed
  1103. |> to be more or less guaranteed the system palette unless you request
  1104. |> something else.  It doesn't seem to work this way.
  1105.  
  1106. I disagree- the palette manager is trying to let apps SHARE the
  1107. palette, so that if apps only allocate (say) 30 colors each,
  1108. they can BOTH get their palettes. CLUT manipulation does not do
  1109. this in any way I can see. If the system palette was restored whenever
  1110. a non-PM app came forward, there would be a lot of flashing and this
  1111. palette sharing would be disturbed.
  1112.  
  1113. Also, NO app can count on having the "default palette" in Color QD. The
  1114. palette manager isn't the only way to mess it up. Some fool user must
  1115. still be using a 4-bit display. Or 2 bit. Or 1 bit. In any of these cases,
  1116. the palette is quite different from the 8 bit. Further, in 4 and 2 bit
  1117. color modes, the palete depends on the current hilight color.
  1118. [with truely nasty effects too. Try steting your hilite color to light blue,
  1119. switching to 4 bit color and using the fidner. light blue icons! :)]
  1120.  
  1121. Apps that dont use the palette manager (or something like that)
  1122. have to be able to deal with this sort of thing, as well as having
  1123. the color environment switched around on them. The finder is one: it
  1124. reverts to 4-bit or b&w icons as needed if the palette gets too warped.
  1125.  
  1126. Incidentally, the Finder IS a palette-using app! It has palettes on its
  1127. windows (including the desktop, but not including the control panels)
  1128. for the LABEL COLORS. But NOT the 34 std-icon-colors. Thats probably
  1129. because the finder CAN draw wo/ the color icons- it uses teh black
  1130. and white versions, but it CANT draw properly wo/ the label colors.
  1131. After all, u can't make an icon "light blue" if theres no light blue in
  1132. the palette. This arrangement does little damange to any cool-looking
  1133. custom-palette windows int the background, yet gives u a working finder
  1134. too.
  1135.  
  1136. |>   Any comments?  As I said, I haven't written an app using the Palette
  1137. |> Wrecker (oops) in a long time, maybe Apple has fixed this sort of thing.
  1138.  
  1139. No, they haven't.
  1140.  
  1141. |> But I seem to recall ResEdit still premanantly fucks up the color
  1142. |> environment (it sort of flips the clut across the line y=x, for
  1143. |> no apparent reason, which confuses the hell out of the Finder), and
  1144. |> presumably it uses the Palette Wrecker.
  1145. |>   Until further notice, I'll count a point for me...
  1146.  
  1147. Go right ahead. It still does that. Like I said, the Palette
  1148. Manager doesn't care what slots the colors go in- so it sez
  1149. "hey lets slow down copybits by putting the palette in BACKWARDS!"
  1150. or something. Quite lame. This only applies to the default palettes,
  1151. tho. [other palettes slow down copybits either way]
  1152.  
  1153. ResEdit is a little crazy with its palettes- it has the default palette
  1154. assigned to a lot of its windows. This makes for loads o flashing,
  1155. as is unecessary (as the resedit rarely makes large changes to the
  1156. palette, the colored icons would look decent anyway. If they didn't
  1157. it would revert to b&w, so its not a big deal.)
  1158.  
  1159. [deletia- entirely redundant stuff, see above and below about
  1160.       apps that dont have their own palettes :)]
  1161.  
  1162. [deletia- its slow, yep it is]
  1163. [deletia- it inreases yer code size, no it doesn't, yes it does, etc]
  1164. |> OK, perhaps you are right on this.  Point for you.  I was thinking
  1165. |> more of the type of CLUT code I tend to write (take over the screen),
  1166. |> whereas you're talking more about QD-in-a-window.
  1167.  
  1168. Yay, annother point! That's 3 now, isn't it?
  1169.  
  1170. [deletia- I am talking about qd-in-a-window, not just direct-to-screen]
  1171. |> Yes, I think I stated my case a little more broadly than I should have.
  1172. |> In many cases the Palette Wrecker does save time & effort, and if it's
  1173. |> a little buggy and annoying (a LITTLE?) well, maybe Apple will fix it
  1174. |> someday.
  1175.  
  1176. I know of no bugs in it myself (yet) but I dont find it annoying
  1177. very often. But I do have one complaint about it:
  1178.  
  1179. if you close a window w/ a palette, or remove the palette from it,
  1180. nothing happens to the color environment. If I am explicitly
  1181. getting RID of a palette, it ought to revert to the default
  1182. IMHO. Right now it assumes if you have a palette, u want those
  1183. colors until you tell it you want some OTHER colors.
  1184.  
  1185. Yech.
  1186.  
  1187. [deletia- PM looks worse, why?]
  1188. |> I recall that when I tried to use the Palette Wrecker (so long ago) to
  1189. |> do stuff, it did not, in fact, like being used to take over very much
  1190. |> of the CLUT.  Everything would be fine until a dialog or something
  1191. |> came up, and then my nice green would suddenly be replaced by an icky
  1192. |> brown (which the dialog didn't even use!)  Of course, this happens with
  1193. |> CLUT setting too, but hey, the Palette Wrecker is supposed to fix such
  1194. |> problems.
  1195.  
  1196. I have never seen this, but it soudns like a bug. I have only
  1197. written 1 prog that takes over the whole palette (less black and white),
  1198. and it has a dialog box (and about box) and it does not have this
  1199. problem.
  1200.  
  1201. Can you give me more specifics?
  1202.  
  1203. |>   BTW, anybody noticed the charming System 7 bug that when the Color Picker
  1204. |> comes up, after you dismiss it it leaves the CLUT fucked up?  Charming.
  1205. |> They haven't fixed that one yet, have they?
  1206.  
  1207. Nope, they haven't. RRRRGH.
  1208.  
  1209. But, if yer window has a palette that palette gets activated, and
  1210. u have your colors back anyway. If you dont, I dunno maybe u r just
  1211. messed up. Sounds like a bug, to me. I hope they fix it, its a pain.
  1212.  
  1213. |> >Anyway, if u r gonna save and restore the clut, how do u force all other
  1214. |> >apps and such to redraw [in teh case where u r not taking over the
  1215. |> >whole screen], and of course also force teh desktop to redraw?
  1216.  
  1217. |> Well, forcing a full refresh is easy, I could post the code if you
  1218. |> really want it.  A few lines.  But only updating the windows that
  1219. |> want a color refresh is not easy, and I conceded that point to you above.
  1220.  
  1221. Well, if its short go ahead, as I have no clue how to do this and
  1222. if you covert me to CLUT-manipulation I will need to know. But
  1223. does it also updated the desktop?
  1224.  
  1225. |> >Also, why is the Palette Manager less compatible than CLUT stuff?
  1226. |> The apps-that-use-the-system-palette problem described above.
  1227.  
  1228. How's that a compatibility prob? They still work. They dont
  1229. have the system palette, but they they already had to deal with
  1230. that.
  1231.  
  1232. |> >|>   Also, if you're using direct-to-screen as almost everyone does - in a
  1233. |> >|> pixel-oriented paint program or in a video game - then you'll want the
  1234. |> >|> whole CLUT to yourself, in which case the Palette Wrecker (even if it
  1235. |> >|> worked) provides no benefits and all the drawbacks.
  1236.  
  1237. |> >Well, the Palette Manager takes care of multiple-monitor setups for you,
  1238. |> >and direct devices. I thot u'd have to special-case for that if
  1239. |> >u r using SetEntries. This doesn't matter if you are taking over the
  1240. |> >screen, but that drawing program ought to run in a window.
  1241.  
  1242. |> Yes, but...suppose it's an 8-bit paint program, in my opinion it would
  1243. |> be dumb to try to display on a 4-bit or less display, you just want to
  1244. |> leave those monitor's CLUTs alone and paint your window with white on
  1245. |> those monitors.  Which the Palette Wrecker won't do.  A loop that sets
  1246. |> all CLUT-driven 8-bit active screen devices to your CLUT is what you
  1247. |> really want in this case, so the PaletteWrecker does you little good.
  1248.  
  1249. Just inhibit all 4-bit devices. No problemo.
  1250. Well, also inhibit all 2 bit devices. Unless u are nuts.
  1251.  
  1252. The drawing in white part has nothing to do with the palette
  1253. manager OR clut-fooling.
  1254.  
  1255. |>   Direct devices, etc. I tend to feel the same way - either they have
  1256. |> enough colors that you can show the 8-bit image on them just doing
  1257. |> matching with Color2Index (why is PmForeColor any better?) or you can't,
  1258. |> in which case you're just going to fill with white.
  1259.  
  1260. I suspect they have enough colors. :)
  1261.  
  1262. PmForeColor is not usefull for direct writing, and it is
  1263. a little shorter and more compatible (Apple's stamp-o-approval. :)
  1264. for QD drawing.
  1265.  
  1266. [deletia- stuff about which I have a point, according to Ben H.]
  1267. |> >|>   OK, I'm ready for the flames... :->
  1268.  
  1269. |> >I tried to be reasonable, and not flame. Mostly because
  1270. |> >I have the feeling that Im way, way out of my depth
  1271. |> >arguing with you. But what the hey. Now pardon me why
  1272. |> >I go dig up my asbestos underwear. I have a feeling
  1273. |> >my ignorance is about to be rudely exposed. :)
  1274.  
  1275. |>   You were very kind not to flame, given the unwise generality of my
  1276. |> original declaration.  I hope this reply didn't seem too hot either, I
  1277. |> think if it's a matter of one or the other of use being right I'd
  1278. |> give the prize to you.  However, I still feel SetEntries is better when
  1279. |> you're either taking over a monitor entirely, or when you want the whole
  1280. |> CLUT to yourself guaranteed.
  1281.  
  1282. Awwwww twernt nothing.
  1283.  
  1284. I now agree that SetEntries is better if u r taking over the whole
  1285. screen. It is also the ONLY way to get teh whole palette to yourself.
  1286. The Palette Manager will NOT touch white or black, EVER.
  1287.  
  1288. |>   Sorry to waste bandwidth on stupid arguments, folks.  I was in a bad
  1289. |> mood yesterday, and didn't phrase my argument as rationally as I might
  1290. |> have...
  1291. |> 
  1292. |> -Ben Haller (deadman@garnet.berkeley.edu)
  1293.  
  1294. I suspect this little thread is about to die, since
  1295. we agree so much. :)
  1296. But if you decide to drop it, please email me that code to
  1297. refreshes the whole screen on ya. Id like to know how ya do that,
  1298. for everything (including menubar+desktop)
  1299.  
  1300. PS my apologies to everyone NOT concered with this for chewing up
  1301. all this bandwidth. :) I tried not to be redundant, repetetive or
  1302. even repeat myself, really I did. Honestly. But well...
  1303.  
  1304. Oh well, here goes nothing. Now where's that send button.. ah..
  1305. ther...
  1306. - -- 
  1307.             - Dan Johnson
  1308. And God said "Jeeze, this is dull"... and it *WAS* dull. Genesis 0:0
  1309.  
  1310. These opinions have had all identifiying marks removed, and are untraceable.
  1311. You'll never know whose they are.
  1312.  
  1313. +++++++++++++++++++++++++++
  1314.  
  1315. From: jmunkki@vipunen.hut.fi (Juri Munkki)
  1316. Date: 9 Sep 92 21:07:29 GMT
  1317. Organization: Helsinki University of Technology
  1318.  
  1319. The Arashi/Storm source code package was missing at least one file.
  1320. I added that file and and cleaned up some other details. (One
  1321. minor bug has been fixed.)
  1322.  
  1323. The new archive should soon be available on ics.uci.edu. The
  1324. directory is pub/mac/think-c/code/. Don't take the file
  1325. if it is older than September 9.
  1326.  
  1327. If you are planning to write an arcade action game for the Mac
  1328. and you are using Think C, I strongly suggest that you take a
  1329. look at the Arashi package.
  1330.  
  1331. - -- 
  1332.   Juri Munkki                           Windsurf: fast sailing
  1333.  jmunkki@hut.fi                          Macintosh: fast software
  1334.  
  1335. +++++++++++++++++++++++++++
  1336.  
  1337. From: bwilliam@iat.holonet.net (Bill Williams)
  1338. Date: 10 Sep 92 05:17:31 GMT
  1339. Organization: HoloNet (BBS: 510-704-1058)
  1340.  
  1341. As much As I can emphasize with Daniel Norman  Johnsonspending time
  1342. defending the merits of programming in a logical and proper manner with
  1343. the proper tools at his disposal, I feel he is missing the point of what
  1344. Ben Haller was trying to really express. HE HATES the inept way Apple
  1345. implemented the Pallette Wrecker and it offends him that it has been
  1346. changed soo many times in the past and that even today merely setting a
  1347. default clut resource with 4 pastell colors of your choice into your
  1348. application will make the entire screen FLASH on context switches EVEN ON
  1349. A 256 color system. Even in system 7.0, even on a quadra. I know I
  1350. experienced it and was sickened. You notice it it for certain when the app
  1351. is launching.
  1352.  
  1353. But on the other hand Ben Haller loses my respect as a person who has
  1354. released products such as Solarian II which (from what I recall) take over
  1355. the screen in a VERY UN-MAC manner. I have written graphics routines
  1356. intended for inclusion in a flight simulator I might finish one day and
  1357. all my routines (lines, ovals, rects, circles, simple polygons, filled and
  1358. hollow of the aforementioned) were ALWAYS faster than quickdraw at every
  1359. depth, but I designed them to work on movable windows. I do not see ANY
  1360. speed advantages in a fixed non-window solution.
  1361.  
  1362. I want DAs, menubars, and windows in everything I run, including games.
  1363.  
  1364. And my games have to use the mouse a proportional positioning device, like
  1365. my hand, rather than a left right toggle switch, or I don't like to play them.
  1366.  
  1367. Yes I know that there are right ways to program but people should
  1368. recognize that the Pallete Wrecker is currently pretty obnoxious, but we
  1369. still should use it.
  1370.  
  1371.  
  1372. Not only is the current pallete manager worthless, but Apple had someone
  1373. type in the indices to the colors as shipped for the current System 7.0
  1374. and the person made a TYPO on one of the crucial grays!!! The color is
  1375. ruined and will never be fixed, its value escapes me now but its effect
  1376. didn't. It made it IMPOSSIBLE to get TWO DAMN NEUTRAL GRAYS off the system
  1377. at times. All I wanted were two grays equal in intensity to the light and
  1378. dark grays used in NeXT and OSF Motif. There were actually three different
  1379. unrelated problems that week long ago, and the blown index in the default
  1380. CLUT might not have been the cause of this second annoying problem.
  1381.  
  1382. If your eyes are quick you will learn to see Pallete flash.
  1383.  
  1384. Also why all this talk about animating palletes now and then? isn't it (1)
  1385. impossible on direct mapped 24 bit devices and (2) only possible at the
  1386. end of a device VBL (governing it not only to 60 per second, but IDLING
  1387. THE CPU during the wait? (not sure if it waits in the trap or not though))
  1388. resulting in an effect leaving 0% free CPU.?
  1389.  
  1390.  
  1391. BWilliams
  1392.  
  1393. +++++++++++++++++++++++++++
  1394.  
  1395. From: timm@void.ncsa.uiuc.edu (Tim McClarren)
  1396. Organization: University of Illinois at Urbana
  1397. Date: Thu, 10 Sep 1992 06:31:20 GMT
  1398.  
  1399. bwilliam@iat.holonet.net (Bill Williams) writes:
  1400.  
  1401. >But on the other hand Ben Haller loses my respect as a person who has
  1402. >released products such as Solarian II which (from what I recall) take over
  1403. >the screen in a VERY UN-MAC manner. I have written graphics routines
  1404. >intended for inclusion in a flight simulator I might finish one day and
  1405. >all my routines (lines, ovals, rects, circles, simple polygons, filled and
  1406. >hollow of the aforementioned) were ALWAYS faster than quickdraw at every
  1407. >depth, but I designed them to work on movable windows. I do not see ANY
  1408. >speed advantages in a fixed non-window solution.
  1409.  
  1410. What's the point?  You want to copy and paste into Solarian?  I can't see
  1411. any advantages in a game really abiding by all the HIGs.  Perhaps adventure
  1412. games, but action games require all your attention anyways.  As for mouse-
  1413. positioning, I don't like relative either, but I must say, I would probably
  1414. find CQ and Solarian much too easy with absolute positioning (after all,
  1415. you'd be able to hyperspace your ship around).
  1416. Tim
  1417.  
  1418. - -- 
  1419. Tim McClarren     | "...a bajillion brilliant Jobsian lithium licks."
  1420. timm@ncsa.uiuc.edu|
  1421. (217)244-0015     |
  1422.  
  1423. +++++++++++++++++++++++++++
  1424.  
  1425. From: triantos@acsu.buffalo.edu (Nick B Triantos)
  1426. Date: 10 Sep 92 14:02:47 GMT
  1427. Organization: The University at Buffalo
  1428.  
  1429. Recently, bwilliam@iat.holonet.net (Bill Williams) writes:
  1430.  
  1431.    Also why all this talk about animating palletes now and then? isn't it (1)
  1432.    impossible on direct mapped 24 bit devices and (2) only possible at the
  1433.    end of a device VBL (governing it not only to 60 per second, but IDLING
  1434.    THE CPU during the wait? (not sure if it waits in the trap or not though))
  1435.    resulting in an effect leaving 0% free CPU.?
  1436.  
  1437. Well, actually, VBL tasks can be activated 60 times / second, but you specify
  1438. how many ticks pass between actual calls to the VBL in <your-VBLTask>.vblCount
  1439. Thus, if you only need your routine to pop up 3 times / second, set vblCount to
  1440. 20. (IM-II, p. 350).  My experience with VBLs is limited only to some ultra-
  1441. simplistic testing I did when I first read about them, and so I'm also unsure
  1442. about whether the task _MUST_ complete before control is resumed to the main
  1443. program.
  1444.  
  1445. I'm really enjoying this thread, as I'm in the early stages of programming an
  1446. action-style game for the Mac, and I really could use the help (my last game
  1447. was on an Apple ][e, and it was in pure 6502 assembler).  If there are other
  1448. people out there who have information about the following, I'd love to see what
  1449. you have to say about:
  1450.  - efficient collision detection algorithms
  1451.  - computer strategy heuristics (e.g. when does the monster shoot, when does
  1452.    the alien lob a bomb at the player, when does the CPU make the checkmate
  1453.    move, etc.  Only some of these things should be purely, random, no?
  1454.  - What type of code does the programmer make "reusable" enough that when his
  1455.    or her next game comes along, he/she doesn't have to start from scratch
  1456.    again
  1457.  - Proper use of VBLs, and the other suggestions Joe Holt had made a few days
  1458.    ago (uses/abuses of off-screen buffers, clut animation, protecting your
  1459.    screen real estate, masking techniques, & assembly language optimizations)
  1460.  
  1461. Who knows?  By the time this thread dies out, there may well be another 10-20
  1462. worthwhile color action games out for the Mac.
  1463.  
  1464. - -Nick
  1465. - --
  1466. Nick Triantos    internet: triantos@acsu.buffalo.edu
  1467.                  AOL:      Triantos
  1468. "Scientists tell us that the fastest animal on earth, with a top speed of
  1469. 120 ft/sec, is a cow that has been dropped out of a helicopter." - Dave Barry
  1470.  
  1471. +++++++++++++++++++++++++++
  1472.  
  1473. From: johnsd2@vccnw07.its.rpi.edu (Daniel Norman Johnson)
  1474. Date: 10 Sep 92 13:28:38 GMT
  1475. Organization: Rensselaer Polytechnic Institute, Troy, NY.
  1476.  
  1477. In article <BuCK18.FE9@iat.holonet.net>, bwilliam@iat.holonet.net (Bill Williams) writes:
  1478. |> As much As I can emphasize with Daniel Norman  Johnsonspending time
  1479.  
  1480. You can call me Dan. :)
  1481.  
  1482. |> defending the merits of programming in a logical and proper manner with
  1483. |> the proper tools at his disposal, I feel he is missing the point of what
  1484. |> Ben Haller was trying to really express.
  1485.  
  1486. I dont think so because....
  1487.  
  1488. |> HE HATES the inept way Apple
  1489. |> implemented the Pallette Wrecker
  1490.  
  1491. I knew this. I just didn't buy his arguement for hating it.
  1492.  
  1493. |> and it offends him that it has been
  1494. |> changed soo many times in the past
  1495.  
  1496. This he didn't say. He probably didn't say it because if it were
  1497. true, he wouldn't know it. He doesn't use the Palette Manager, if
  1498. you recall. :)
  1499.  
  1500. Incidentally, to what changes are you refering? The only ones
  1501. I rememeber is that when 32-bit QD came out, the palette manager
  1502. learned to deal with direct devices, and when 32 bit QD, version
  1503. 1.2 appeared pmTolerant+pmExplicit, pmAnimated+pmExplicit and inhibitions
  1504. were added. These things have no effect on progs/systems that do not
  1505. use these features, of course, so I dont quite see whats wrong.
  1506.  
  1507. |> and that even today merely setting a
  1508. |> default clut resource with 4 pastell colors of your choice into your
  1509. |> application will make the entire screen FLASH on context switches EVEN ON
  1510. |> A 256 color system.
  1511.  
  1512. This can be true. When teh colors are first activated, there is such a flash.
  1513. There will also be flashes on context switches if there aren't
  1514. enough colors to go around. However, if we are just talking about 1
  1515. app with 4 colors, plus the finder, it shouldn't flash in 256 colors.
  1516.  
  1517. Ive never tried this example exactly, but if you'll believe it, 5 colors
  1518. (some grays, a green, a red, a light-purple) on a 4 bit display don't
  1519. produce this effect. Of course, maybe the Palette Manager just hates
  1520. pastel colors. :)
  1521.  
  1522. |> Even in system 7.0, even on a quadra.
  1523. |> I know I
  1524. |> experienced it and was sickened. You notice it it for certain when the app
  1525. |> is launching.
  1526.  
  1527. Yeah, when teh app launches you DO see the flash, because the
  1528. palette is being changed. No getting around it. And the Palette Manager
  1529. forces a redraw of all windows that dont tell it not to, and the
  1530. desktop, etc, when this happens. I personally think this is better
  1531. then just having bizzare colors. Perhaps you disagree.
  1532.  
  1533. |> But on the other hand Ben Haller loses my respect as a person who has
  1534. |> released products such as Solarian II which (from what I recall) take over
  1535. |> the screen in a VERY UN-MAC manner. I have written graphics routines
  1536. |> intended for inclusion in a flight simulator I might finish one day and
  1537. |> all my routines (lines, ovals, rects, circles, simple polygons, filled and
  1538. |> hollow of the aforementioned) were ALWAYS faster than quickdraw at every
  1539. |> depth, but I designed them to work on movable windows. I do not see ANY
  1540. |> speed advantages in a fixed non-window solution.
  1541. |>
  1542. |> I want DAs, menubars, and windows in everything I run, including games.
  1543. |> 
  1544. |> And my games have to use the mouse a proportional positioning device, like
  1545. |> my hand, rather than a left right toggle switch, or I don't like to play them.
  1546. |> 
  1547.  
  1548. This sounds like personal preference to me. I often like games that
  1549. take over teh screen, myself. So there! Nyaa nyaa! :)
  1550.  
  1551. |> Yes I know that there are right ways to program but people should
  1552. |> recognize that the Pallete Wrecker is currently pretty obnoxious, but we
  1553. |> still should use it.
  1554.  
  1555. I dunno.. I think we should use it if it helps. Sometimes it doesn't.
  1556. Like if u r taking over the whole screen.
  1557.  
  1558. |> 
  1559. |> Not only is the current pallete manager worthless,
  1560.  
  1561. Doesn't this contradict what u just said? If its worthless
  1562. why use it?
  1563.  
  1564. |> but Apple had someone
  1565. |> type in the indices to the colors as shipped for the current System 7.0
  1566. |> and the person made a TYPO on one of the crucial grays!!!
  1567.  
  1568. Which one? I have never noticed this. In any case, there are a lot
  1569. of grays so this is not so critical.
  1570.  
  1571. |> The color is
  1572. |> ruined and will never be fixed,
  1573.  
  1574. Huh? why not?
  1575.  
  1576. |> its value escapes me now but its effect
  1577. |> didn't. It made it IMPOSSIBLE to get TWO DAMN NEUTRAL GRAYS off the system
  1578. |> at times.
  1579.  
  1580. The palette manager could have netted you any grays you like,
  1581. without regard for what is in the various system palettes.
  1582.  
  1583. |> All I wanted were two grays equal in intensity to the light and
  1584. |> dark grays used in NeXT and OSF Motif. There were actually three different
  1585. |> unrelated problems that week long ago, and the blown index in the default
  1586. |> CLUT might not have been the cause of this second annoying problem.
  1587.  
  1588. Ok.
  1589.  
  1590. |> If your eyes are quick you will learn to see Pallete flash.
  1591.  
  1592. I can already see the flash, when it happens. Its very dramatic- the whole
  1593. screen redraws, in general. Sometimes the desktop refresh isn't very
  1594. noticable (its drawing the same pattern onto itself, so if the pattern
  1595. wasn't disturbed not much happens) [<- thats just from my observations,
  1596. not any real source. Maybe something else happens, but it looks like that]
  1597. but the finder windows are erased and redrawn. I can really truely
  1598. see this. Honest, honest. :)
  1599.  
  1600. |> Also why all this talk about animating palletes now and then? isn't it (1)
  1601. |> impossible on direct mapped 24 bit devices and (2) only possible at the
  1602. |> end of a device VBL (governing it not only to 60 per second, but IDLING
  1603. |> THE CPU during the wait? (not sure if it waits in the trap or not though))
  1604. |> resulting in an effect leaving 0% free CPU.?
  1605.  
  1606. Color animation is still usefull. It does not work on direct divices,
  1607. but Ill wager any 24 bit device can be run in 8 bits too. So put up
  1608. a dialog asking if the user wants to switch to 8 bit color, or quit, or
  1609. watch the program break.
  1610.  
  1611. - -- 
  1612.             - Dan Johnson
  1613. And God said "Jeeze, this is dull"... and it *WAS* dull. Genesis 0:0
  1614.  
  1615. These opinions have had all identifiying marks removed, and are untraceable.
  1616. You'll never know whose they are.
  1617.  
  1618. +++++++++++++++++++++++++++
  1619.  
  1620. From: ross@bnr.ca (Ross Brown)
  1621. Date: 10 Sep 92 14:56:56 GMT
  1622. Organization: Bell-Northern Research
  1623.  
  1624. In article <BuD5Kr.6x2@acsu.buffalo.edu> triantos@acsu.buffalo.edu (Nick B
  1625. Triantos) writes:
  1626. >[stuff deleted]
  1627. >Who knows?  By the time this thread dies out, there may well be another 10-20
  1628. >worthwhile color action games out for the Mac.
  1629.  
  1630. I enjoy games as much as the next guy, but...
  1631. Please end the cross-posting, and continue the thread in c.s.m.g only.  Thanks.
  1632.  
  1633. ==============================================================================
  1634. Ross Brown, Dept. 7C22  < Bell-Northern Research     >  Just the facts, ma'am.
  1635. Advisor, Telemgmt Svcs  < P. O. Box 3511, Station C  >  We don't care whose
  1636. ross@bnr.ca             < Ottawa, ON, Canada K1Y 4H7 >  opinions yours aren't.
  1637. ==============================================================================
  1638.  
  1639. +++++++++++++++++++++++++++
  1640.  
  1641. From: triantos@acsu.buffalo.edu (Nick B Triantos)
  1642. Date: 10 Sep 92 17:27:54 GMT
  1643. Organization: The University at Buffalo
  1644.  
  1645. In article <1992Sep10.145656.4345@bmers95.bnr.ca> ross@bnr.ca (Ross Brown) writes:
  1646.  
  1647. >>I [Nick Triantos] recently write:
  1648. >>[stuff deleted]
  1649. >>Who knows?  By the time this thread dies out, there may well be another 10-20
  1650. >>worthwhile color action games out for the Mac.
  1651.  
  1652. >I enjoy games as much as the next guy, but...
  1653. >Please end the cross-posting, and continue the thread in c.s.m.g only.  Thanks.
  1654.  
  1655. Most of this thread, including my suggestions in the last posting are directly
  1656. related to the PROGRAMMING of games.  What more apropriate newsgroup than
  1657. c.s.m.p.?  If you don't like reading them, just add them to a kill file.
  1658.  
  1659. Sheesh.
  1660.  
  1661. - -Nick
  1662. - --
  1663. Nick Triantos    internet: triantos@acsu.buffalo.edu
  1664.                  AOL:      Triantos
  1665. "Scientists tell us that the fastest animal on earth, with a top speed of
  1666. 120 ft/sec, is a cow that has been dropped out of a helicopter." - Dave Barry
  1667.  
  1668. +++++++++++++++++++++++++++
  1669.  
  1670. From: timm@void.ncsa.uiuc.edu (Tim McClarren)
  1671. Date: 10 Sep 92 23:12:27 GMT
  1672. Organization: University of Illinois at Urbana
  1673.  
  1674. triantos@acsu.buffalo.edu (Nick B Triantos) writes:
  1675.  
  1676. >In article <1992Sep10.145656.4345@bmers95.bnr.ca> ross@bnr.ca (Ross Brown) writes:
  1677.  
  1678. >>>I [Nick Triantos] recently write:
  1679. >>>[stuff deleted]
  1680. >>>Who knows?  By the time this thread dies out, there may well be another 10-20
  1681. >>>worthwhile color action games out for the Mac.
  1682.  
  1683. >>I enjoy games as much as the next guy, but...
  1684. >>Please end the cross-posting, and continue the thread in c.s.m.g only.  Thanks.
  1685.  
  1686. >Most of this thread, including my suggestions in the last posting are directly
  1687. >related to the PROGRAMMING of games.  What more apropriate newsgroup than
  1688. >c.s.m.p.?  If you don't like reading them, just add them to a kill file.
  1689.  
  1690. >Sheesh.
  1691.  
  1692. c.s.m.p is the appropriate newsgroup, if anything, it shouldn't be 
  1693. cross-posted to games.  Anyways, I too would be interested in eff.
  1694. collision detection algorithms.
  1695. Tim
  1696.  
  1697. - -- 
  1698. Tim McClarren     | "...a bajillion brilliant Jobsian lithium licks."
  1699. timm@ncsa.uiuc.edu|
  1700. (217)244-0015     |
  1701.  
  1702. +++++++++++++++++++++++++++
  1703.  
  1704. From: deadman@garnet.berkeley.edu (Ben Haller)
  1705. Date: 10 Sep 92 23:57:59 GMT
  1706. Organization: Stick Software
  1707.  
  1708. In article <ah5ywvd@rpi.edu> johnsd2@rpi.edu writes:
  1709. >[huge amounts deleted...]
  1710. >Doesn't this depend on the order in which these events happen? Is
  1711. >it garaounteed that suspends come before resumes? If not, then
  1712. >you could wind up "saving" the wrong CLUT.
  1713. >
  1714. >Also, what if you dont want all the colors?
  1715.   I don't think you can get two suspends or two resumes in a row.  If
  1716. you did, I bet a lot more than the CLUT would break, in a lot of
  1717. apps...
  1718.  
  1719. >Also, NO app can count on having the "default palette" in Color QD. The
  1720. >palette manager isn't the only way to mess it up. Some fool user must
  1721. >still be using a 4-bit display. Or 2 bit. Or 1 bit. In any of these cases,
  1722. >the palette is quite different from the 8 bit. Further, in 4 and 2 bit
  1723. >color modes, the palete depends on the current hilight color.
  1724. >[with truely nasty effects too. Try steting your hilite color to light blue,
  1725. >switching to 4 bit color and using the fidner. light blue icons! :)]
  1726. >
  1727. >Apps that dont use the palette manager (or something like that)
  1728. >have to be able to deal with this sort of thing, as well as having
  1729. >the color environment switched around on them. The finder is one: it
  1730. >reverts to 4-bit or b&w icons as needed if the palette gets too warped.
  1731. Well really this is a part of my problem with their scheme.  If all
  1732. you want is the system palette, you can either use the palette manager
  1733. to install that palette (gets the colors in the wrong order, slows down
  1734. CopyBits), use SetEntries (compatability problems, etc.), or go through
  1735. all of these labyrinthine tests to determine whether the clut is within
  1736. a sufficient tolerance of the system CLUT.  The Finder (as far as I know
  1737. it is still this, 7.0 was...) doesn't actually do a CLUT compare, it
  1738. compares the ctSeed value!  Which means if you set the CLUT with SetEntries
  1739. and the ctSeed changes (which it always does) the Finder will barf, even
  1740. if the CLUT you set is the system CLUT!  No, wait I'm misremembering this.
  1741. It checks the ctSeed to see if it *needs* to check the CLUTs.  But if
  1742. you're in grayscale, and you set the CLUT to the standard grayscale CLUT
  1743. (gray ramp), the ctSeed changes, the Finder does a compare of all the
  1744. colors in the current CLUT - but against the *color* CLUT for the bit
  1745. depth you're in.  And so of course the compare fails, the color and
  1746. grayscale CLUTs being different.  And so all your icons are then 1-bit,
  1747. until you tweak the monitor or reboot.  And now I remember, they did
  1748. "fix" this problem - they changed the grayscale CLUT to be the same as
  1749. the color CLUT, instead of a grayscale ramp!  Love those bug fixes.
  1750.   Anyhow, the point is, it should be *easy* to write an app that likes
  1751. the default palette.  But as it is, writing such an app is actually
  1752. *harder* than writing an app that installs a custom palette (thus causing
  1753. flashes, slowness, etc.)  This is not the way things should be.
  1754.  
  1755. >Incidentally, the Finder IS a palette-using app! It has palettes on its
  1756. >windows (including the desktop, but not including the control panels)
  1757. >for the LABEL COLORS. But NOT the 34 std-icon-colors. Thats probably
  1758. >because the finder CAN draw wo/ the color icons- it uses teh black
  1759. >and white versions, but it CANT draw properly wo/ the label colors.
  1760. >After all, u can't make an icon "light blue" if theres no light blue in
  1761. >the palette. This arrangement does little damange to any cool-looking
  1762. >custom-palette windows int the background, yet gives u a working finder
  1763. >too.
  1764.   It is also fairly easy to get the finder to permanantly draw the
  1765. window backgrounds in beige rather than white (even white is in
  1766. entry 0 of the CLUT), and to draw text white-on-black (again, with
  1767. a normal CLUT).  Temporarily setting white and black to other colors will
  1768. tweak it beyond repair, and then even if you put the system CLUT
  1769. back in it will be confused.
  1770.  
  1771. >|> In many cases the Palette Wrecker does save time & effort, and if it's
  1772. >|> a little buggy and annoying (a LITTLE?) well, maybe Apple will fix it
  1773. >I know of no bugs in it myself (yet) but I dont find it annoying
  1774. >very often. But I do have one complaint about it:
  1775. I think many of the things that you might just consider annoying,
  1776. I consider bugs.  A design flaw is a bug.
  1777.   I think you also have more patience with Apple than I do...
  1778.   But then, how many years is it *supposed* to take until you can
  1779. play sounds without crashing, hanging, or silencing the speaker?
  1780. It's been 8...
  1781.  
  1782. >|> I recall that when I tried to use the Palette Wrecker (so long ago) to
  1783. >|> do stuff, it did not, in fact, like being used to take over very much
  1784. >|> of the CLUT.  Everything would be fine until a dialog or something
  1785. >|> came up, and then my nice green would suddenly be replaced by an icky
  1786. >|> brown (which the dialog didn't even use!)  Of course, this happens with
  1787. >|> CLUT setting too, but hey, the Palette Wrecker is supposed to fix such
  1788. >|> problems.
  1789. >I have never seen this, but it soudns like a bug. I have only
  1790. >written 1 prog that takes over the whole palette (less black and white),
  1791. >and it has a dialog box (and about box) and it does not have this
  1792. >problem.
  1793.   I'm quite certain of this.  Just set the CLUT to, say, a ramp from
  1794. white to black, and then bring up some dialogs and stuff.  This is
  1795. System 6 & 7.  It will shove nasty colors in there and not take them
  1796. out.  Very annoying.  At least, it does it on my machine :->
  1797.  
  1798. >|> >Anyway, if u r gonna save and restore the clut, how do u force all other
  1799. >|> >apps and such to redraw [in teh case where u r not taking over the
  1800. >|> >whole screen], and of course also force teh desktop to redraw?
  1801. >
  1802. >|> Well, forcing a full refresh is easy, I could post the code if you
  1803. >|> really want it.  A few lines.  But only updating the windows that
  1804. >|> want a color refresh is not easy, and I conceded that point to you above.
  1805. >
  1806. >Well, if its short go ahead, as I have no clue how to do this and
  1807. >if you covert me to CLUT-manipulation I will need to know. But
  1808. >does it also updated the desktop?
  1809. Here's the code:
  1810.  
  1811. void InvalScreen()
  1812. {
  1813.     DrawMenuBar();
  1814.     PaintOne(0L,GrayRgn);
  1815.     PaintBehind(WindowList,GrayRgn);
  1816. }
  1817.  
  1818. I believe this is the only code I have ever posted that is copied
  1819. directly from Solarian II, so all you people who have been slavering
  1820. over the (imagined) prospect of getting Sol source out of my tight
  1821. little fists, rejoice!
  1822.   It does redraw the desktop.  It also seems to work in MultiFinder,
  1823. for reasons that I free admit to not understanding.  I wish they
  1824. would document what the window manager *means* in MultiFinder...
  1825.  
  1826. >|> those monitors.  Which the Palette Wrecker won't do.  A loop that sets
  1827. >|> all CLUT-driven 8-bit active screen devices to your CLUT is what you
  1828. >|> really want in this case, so the PaletteWrecker does you little good.
  1829. >
  1830. >Just inhibit all 4-bit devices. No problemo.
  1831. >Well, also inhibit all 2 bit devices. Unless u are nuts.
  1832. >
  1833. >The drawing in white part has nothing to do with the palette
  1834. >manager OR clut-fooling.
  1835. So the Palette Manager lets you say "this is the palette I want for this
  1836. window, but only touch windows that are 8-bit"?  I had no idea.  That's
  1837. nice.
  1838.  
  1839. >I now agree that SetEntries is better if u r taking over the whole
  1840. >screen. It is also the ONLY way to get teh whole palette to yourself.
  1841. >The Palette Manager will NOT touch white or black, EVER.
  1842. One of the more obscure areas of knowledge is "which parts of
  1843. QuickDraw continue to work when black and white are not in their
  1844. accustomed places?"  Due to a stupid design flaw in Solarian II,
  1845. I'm pretty familiar with this issue...
  1846.  
  1847.   Amusing fact: you, and so many others, dread going as low-level as
  1848. SetEntries.  Me, I've had to resort to calling the video driver
  1849. directly, because I considered SetEntries too slow...  And recently
  1850. I've been wondering if there isn't a way to get even lower-level -
  1851. some of those video drivers are pretty badly written, if you want to
  1852. get 60-75 CLUT switches a second...
  1853.  
  1854.   So, pretty much the end of this thread, I think...
  1855.  
  1856. - -Ben Haller (deadman@garnet.berkeley.edu)
  1857.  
  1858. +++++++++++++++++++++++++++
  1859.  
  1860. From: deadman@garnet.berkeley.edu (Ben Haller)
  1861. Date: 11 Sep 92 00:21:17 GMT
  1862. Organization: Stick Software
  1863.  
  1864. In article <BuCK18.FE9@iat.holonet.net> bwilliam@iat.holonet.net (Bill Williams) writes:
  1865. >...I feel he is missing the point of what
  1866. >Ben Haller was trying to really express. HE HATES the inept way Apple
  1867. >implemented the Pallette Wrecker and it offends him...
  1868. Thank you, you expressed this very nicely.
  1869.  
  1870. >But on the other hand Ben Haller loses my respect as a person who has
  1871. >released products such as Solarian II which (from what I recall) take over
  1872. >the screen in a VERY UN-MAC manner. I have written graphics routines
  1873. >intended for inclusion in a flight simulator I might finish one day and
  1874. >all my routines (lines, ovals, rects, circles, simple polygons, filled and
  1875. >hollow of the aforementioned) were ALWAYS faster than quickdraw at every
  1876. >depth, but I designed them to work on movable windows. I do not see ANY
  1877. >speed advantages in a fixed non-window solution.
  1878.   Oh, no, no speed advantages.  That isn't why I designed Solarian II
  1879. the way I did.  I have written *many* graphics routines that are
  1880. origin independant, do region clipping, etc.  That isn't the problem.
  1881.   The reason Solarian II has no Mac interface is that it is supposed to
  1882. look like an arcade game.  As far as I'm concerned, things like
  1883. menubar, windows from other applications, etc. are pure distraction
  1884. when you're trying to play a video game, and they also ruin the mood
  1885. of the game.  Video games should look like the games you play in
  1886. a real video arcade, if possible.  I only regret that the Mac doesn't
  1887. ship with a joystick...
  1888.   I think this point of view is quite defensible...imagine if you're
  1889. trying to play a game using the mouse, and you accidentally click outside
  1890. of it's correctly-Mac-interfacey window, do a context, and your enemies
  1891. kick your ass while you're fumbling around trying to get back to the
  1892. game (you could say "pause the game", but it's still annoying, and what
  1893. about networked games?  You could say "hide the menubar during play"
  1894. and stuff, but then isn't this exactly what Solarian II does?)
  1895.   I think it's even more defensible from an aesthetic view...
  1896.  
  1897. >I want DAs, menubars, and windows in everything I run, including games.
  1898.   Well, I think you're in a minority.  And in any case, I make
  1899. aesthetic decisions based on *my* aesthetics, which makes the point moot -
  1900. I consider the choice I made to be correct, public opinion be damned.
  1901.  
  1902. >And my games have to use the mouse a proportional positioning device, like
  1903. >my hand, rather than a left right toggle switch, or I don't like to play them.
  1904.   A "left right toggle switch" being the way Solarian II works?
  1905. Actually, Solarian's mouse control is more subtle than this, and it was
  1906. very carefully designed.  You would hate life if Solarian II used the mouse
  1907. as a "proportional positioning device", you wouldn't be able to move
  1908. continuously...
  1909.   Well, wait.  Do you absolute positioning or relative positioning?  Really,
  1910. there are so many way to use the mouse, different ways suit different games
  1911. or applications, and I think it's dumb to say "I hate all games that don't
  1912. use the mouse *my* way."  The way Crystal Quest uses the mouse feels
  1913. very difficult to control initially, but after you get good at it it gives
  1914. you the perfect kind of control for the game.  I think that the mouse
  1915. control is probably my favorite thing about that game.
  1916.  
  1917. >Yes I know that there are right ways to program but people should
  1918. >recognize that the Pallete Wrecker is currently pretty obnoxious, but we
  1919. >still should use it.
  1920.   Why bother?  When they fix it, they'll probably put a whole new API
  1921. on, that seems to be what they do with things as broken as it is...
  1922.   Oh, but we've argued this to death, don't let's reopen it...
  1923.  
  1924. >Not only is the current pallete manager worthless, but Apple had someone
  1925. >type in the indices to the colors as shipped for the current System 7.0
  1926. >and the person made a TYPO on one of the crucial grays!!! The color is
  1927. >ruined and will never be fixed, its value escapes me now but its effect
  1928. >didn't. It made it IMPOSSIBLE to get TWO DAMN NEUTRAL GRAYS off the system
  1929. >at times. All I wanted were two grays equal in intensity to the light and
  1930. >dark grays used in NeXT and OSF Motif.
  1931. Here you are on drugs, I believe (metaphorically, at least).  The
  1932. System 7 CLUT is just fine.  I feel pretty sure of this.  Want to
  1933. specify which color you think is bad?  The grayscale ramp at the end
  1934. of the CLUT isn't *supposed* to be a smooth ramp, you know.  The
  1935. missing grays are to be found elsewhere in the CLUT.  And you know,
  1936. I'd be incredibly surprised if they had someone *type in* the CLUT
  1937. values, since it can be (much more easily) generated with a few lines
  1938. of code, being a simple algorithmically-generable color set...
  1939.  
  1940. >Also why all this talk about animating palletes now and then? isn't it (1)
  1941. >impossible on direct mapped 24 bit devices and (2) only possible at the
  1942. >end of a device VBL (governing it not only to 60 per second, but IDLING
  1943. >THE CPU during the wait? (not sure if it waits in the trap or not though))
  1944. >resulting in an effect leaving 0% free CPU.?
  1945.   It is impossible on 24-bit devices, although on these you can do
  1946. gamma animation instead (although the Palette Manager doesn't support this)
  1947.  Some video drivers wait on the VBL, some don't.  Which is very annoying.
  1948. But all you have to do (all you have to do - it's easy!) is do all of your
  1949. other processing at interrupt time, and then you'll be fine, the delay loop
  1950. in the video driver won't bother you at all...
  1951.   It should also be possible to use a combination of a slotVBL and a
  1952. Time Manager task (and a Deferred Task too, I suppose) to get rid
  1953. of the delay loop...
  1954.  
  1955. - -Ben Haller (deadman@garnet.berkeley.edu)
  1956.  
  1957. +++++++++++++++++++++++++++
  1958.  
  1959. From: deadman@garnet.berkeley.edu (Ben Haller)
  1960. Date: 11 Sep 1992 00:30:45 GMT
  1961. Organization: Stick Software
  1962.  
  1963. In article <BuD5Kr.6x2@acsu.buffalo.edu> triantos@acsu.buffalo.edu (Nick B Triantos) writes:
  1964. >Recently, bwilliam@iat.holonet.net (Bill Williams) writes:
  1965. >   Also why all this talk about animating palletes now and then? isn't it (1)
  1966. >   impossible on direct mapped 24 bit devices and (2) only possible at the
  1967. >   end of a device VBL (governing it not only to 60 per second, but IDLING
  1968. >   THE CPU during the wait? (not sure if it waits in the trap or not though))
  1969. >   resulting in an effect leaving 0% free CPU.?
  1970. >
  1971. >Well, actually, VBL tasks can be activated 60 times / second, but you specify
  1972. >how many ticks pass between actual calls to the VBL in <your-VBLTask>.vblCount
  1973. >Thus, if you only need your routine to pop up 3 times / second, set vblCount to
  1974. >20. (IM-II, p. 350).  My experience with VBLs is limited only to some ultra-
  1975. >simplistic testing I did when I first read about them, and so I'm also unsure
  1976. >about whether the task _MUST_ complete before control is resumed to the main
  1977. >program.
  1978.   No, he's not talking about calling SetEntries from a VBL, he's talking
  1979. about the SetEntries routine (or actually, the video driver) waiting in a
  1980. tight loop for the gun to get to a certain point before doing the
  1981. SetEntries operation.  See my other post in this thread (no, not that other
  1982. post, the *other* other post - god this is a busy thread!)
  1983.  
  1984. >I'm really enjoying this thread, as I'm in the early stages of programming an
  1985. >action-style game for the Mac, and I really could use the help (my last game
  1986. >was on an Apple ][e, and it was in pure 6502 assembler).  If there are other
  1987. >people out there who have information about the following, I'd love to see what
  1988. >you have to say about:
  1989.  
  1990. > - efficient collision detection algorithms
  1991.   My current favorite is, keep a sorted list of sprites (keeping it
  1992. sorted, assuming your sprites don't constantly teleport, is O(n)) and
  1993. compare nearby elements in the sorted list (again, O(n) for normal cases).
  1994. If you get a bounding box intersection, do a mask compare.  This is
  1995. pretty efficient, I think.  I hope...
  1996.  
  1997. > - computer strategy heuristics (e.g. when does the monster shoot, when does
  1998. >   the alien lob a bomb at the player, when does the CPU make the checkmate
  1999. >   move, etc.  Only some of these things should be purely, random, no?
  2000. You certainly need non-random elements.  I usually have things like a
  2001. time delay that the enemy has to wait before firing again, things
  2002. like that.  You will find that it's easy to make bad guys that cream
  2003. human players.  The hard thing is to make well-balanced enemies, or
  2004. enemies that behave in an interesting way.  Books could be written
  2005. on this subject...
  2006.  
  2007. > - What type of code does the programmer make "reusable" enough that when his
  2008. >   or her next game comes along, he/she doesn't have to start from scratch
  2009. Everything you can!  I generally don't even attempt to make the
  2010. display code general beyond a reasonable point, it is just a fact
  2011. of life that virtually every game requires you to rewrite your
  2012. graphics code...assuming you want to be fast...
  2013.   Everything about dealing with keyboard/mouse, displays, high scores,
  2014. sounds, etc etc should be as portable as possible.
  2015.   The logic that moves the bad guys and stuff will be game-specific,
  2016. unless you want the same bad guy in two games...
  2017.  
  2018. > - Proper use of VBLs, and the other suggestions Joe Holt had made a few days
  2019. >   ago (uses/abuses of off-screen buffers, clut animation, protecting your
  2020. >   screen real estate, masking techniques, & assembly language optimizations)
  2021.   Boy, quite a bit could be written about all this.  Want to ask a slightly
  2022. less broad question relating to something you're actually trying to
  2023. do *right now*?  Just to narrow it down a bit...
  2024.  
  2025. - -Ben Haller (deadman@garnet.berkeley.edu)
  2026.  
  2027. +++++++++++++++++++++++++++
  2028.  
  2029. From: johnsd2@vccsouth21.its.rpi.edu (Daniel Norman Johnson)
  2030. Date: 11 Sep 92 01:57:12 GMT
  2031. Organization: Rensselaer Polytechnic Institute, Troy, NY.
  2032.  
  2033. In article <18one7INNm74@agate.berkeley.edu>, deadman@garnet.berkeley.edu (Ben Haller) writes:
  2034. |> In article <ah5ywvd@rpi.edu> johnsd2@rpi.edu writes:
  2035. |> >[huge amounts deleted...]
  2036. |> >Doesn't this depend on the order in which these events happen? Is
  2037. |> >it garaounteed that suspends come before resumes? If not, then
  2038. |> >you could wind up "saving" the wrong CLUT.
  2039. |> >
  2040. |> >Also, what if you dont want all the colors?
  2041. |>   I don't think you can get two suspends or two resumes in a row.  If
  2042. |> you did, I bet a lot more than the CLUT would break, in a lot of
  2043. |> apps...
  2044.  
  2045. My apps wouldn't, but that's beside the point.
  2046.  
  2047. This is not the case I was talking about. Let me try again.
  2048.  
  2049. Lets say we have two apps that use clut switching, instead of
  2050. palette wrecking or just taking their punishment like a good
  2051. little app. :)
  2052.  
  2053. Call them "Mongo Colors" and "Freds Neato Picture Program". Just to
  2054. waste bandwidth. :)
  2055.  
  2056. Start 'em both. Say mongo-colors is in front, and so far all is well.
  2057. Now bring Freds Picture Prog to the front. NOW, if Mong-Colors
  2058. gets a suspend and THEN fred's gets a resume, all is well.
  2059.  
  2060. If freds gets a resume, THEN mongo gets a suspend, things are not well.
  2061. Because fred will resume and save the "old" color environment, and
  2062. institute its own. the environment it is saving however is really
  2063. mongos! Then mongo replaces "its" environment with ITS saved version.
  2064. But its really replaces freds, which will mess fred up of course. AND
  2065. it will throw sand in the wheels of the mechanism that restores
  2066. freds palette, since its restoring the wrong thing. Mongo remains
  2067. blissfully ignorant tho.
  2068.  
  2069. However, is the order is guarantted to be suspend then resume,
  2070. all is well. Is it? [alternaately, maybe I have no clue.]
  2071.  
  2072. |> >Also, NO app can count on having the "default palette" in Color QD. The
  2073. |> >palette manager isn't the only way to mess it up. Some fool user must
  2074. |> >still be using a 4-bit display. Or 2 bit. Or 1 bit. In any of these cases,
  2075. |> >the palette is quite different from the 8 bit. Further, in 4 and 2 bit
  2076. |> >color modes, the palete depends on the current hilight color.
  2077. |> >[with truely nasty effects too. Try steting your hilite color to light blue,
  2078. |> >switching to 4 bit color and using the fidner. light blue icons! :)]
  2079. |> >
  2080. |> >Apps that dont use the palette manager (or something like that)
  2081. |> >have to be able to deal with this sort of thing, as well as having
  2082. |> >the color environment switched around on them. The finder is one: it
  2083. |> >reverts to 4-bit or b&w icons as needed if the palette gets too warped.
  2084.  
  2085. |> Well really this is a part of my problem with their scheme.  If all
  2086. |> you want is the system palette, you can either use the palette manager
  2087. |> to install that palette (gets the colors in the wrong order, slows down
  2088. |> CopyBits), use SetEntries (compatability problems, etc.), or go through
  2089. |> all of these labyrinthine tests to determine whether the clut is within
  2090. |> a sufficient tolerance of the system CLUT.
  2091.  
  2092. This can be done for your by the palette manager. Convert the default
  2093. clut you want to a palette, set all of its tolerances to something
  2094. reasonable, set the usage to pmTolerant. It will do nothing
  2095. in the case that the system palette IS there, and will fix the
  2096. palette in case it isn't.
  2097.  
  2098. |>  The Finder (as far as I know
  2099. |> it is still this, 7.0 was...) doesn't actually do a CLUT compare, it
  2100. |> compares the ctSeed value!  Which means if you set the CLUT with SetEntries
  2101. |> and the ctSeed changes (which it always does) the Finder will barf, even
  2102. |> if the CLUT you set is the system CLUT!  No, wait I'm misremembering this.
  2103. |> It checks the ctSeed to see if it *needs* to check the CLUTs.  But if
  2104. |> you're in grayscale, and you set the CLUT to the standard grayscale CLUT
  2105. |> (gray ramp), the ctSeed changes, the Finder does a compare of all the
  2106. |> colors in the current CLUT - but against the *color* CLUT for the bit
  2107. |> depth you're in.  And so of course the compare fails, the color and
  2108. |> grayscale CLUTs being different.  And so all your icons are then 1-bit,
  2109. |> until you tweak the monitor or reboot.  And now I remember, they did
  2110. |> "fix" this problem - they changed the grayscale CLUT to be the same as
  2111. |> the color CLUT, instead of a grayscale ramp!  Love those bug fixes.
  2112.  
  2113. This is NOT at all what happens on my mac anyway. Gray scale
  2114. still means gray ramp. the finder icons still draw right. They
  2115. draw they way they would if resedit had reversed the palette on them-
  2116. a bit slower. Because they need to compare RGB values and all that.
  2117. They do NOT revert to b&w! [however, u'd think it could use the 8 bit
  2118. icons in 4 bit mode when in grayscale, and it does not do this]
  2119.  
  2120. |>   Anyhow, the point is, it should be *easy* to write an app that likes
  2121. |> the default palette.  But as it is, writing such an app is actually
  2122. |> *harder* than writing an app that installs a custom palette (thus causing
  2123. |> flashes, slowness, etc.)  This is not the way things should be.
  2124.  
  2125. Funny, I find it easier not to use the palette, despite the fact
  2126. that I cannot assume that I will have exactly the colors I expect.
  2127. I have to use device-independant methods to do everything- the moreso
  2128. the better. MakeRGBPat, fer instance. icon families. That sorta thing.
  2129.  
  2130. |> >Incidentally, the Finder IS a palette-using app! It has palettes on its
  2131. |> >windows (including the desktop, but not including the control panels)
  2132. |> >for the LABEL COLORS. But NOT the 34 std-icon-colors. Thats probably
  2133. |> >because the finder CAN draw wo/ the color icons- it uses teh black
  2134. |> >and white versions, but it CANT draw properly wo/ the label colors.
  2135. |> >After all, u can't make an icon "light blue" if theres no light blue in
  2136. |> >the palette. This arrangement does little damange to any cool-looking
  2137. |> >custom-palette windows int the background, yet gives u a working finder
  2138. |> >too.
  2139. |>   It is also fairly easy to get the finder to permanantly draw the
  2140. |> window backgrounds in beige rather than white (even white is in
  2141. |> entry 0 of the CLUT), and to draw text white-on-black (again, with
  2142. |> a normal CLUT).  Temporarily setting white and black to other colors will
  2143. |> tweak it beyond repair, and then even if you put the system CLUT
  2144. |> back in it will be confused.
  2145.  
  2146. This may be why the palette manager will never let you change black
  2147. or white. [is that what u mean? if u change black or white the
  2148. finder is mucked up beyond repair?]
  2149.  
  2150. I dont know of any way to use the Palette MAnager to muck up the finder
  2151. beyond repair. 
  2152.  
  2153. [a little deletia]
  2154. |> >I know of no bugs in it myself (yet) but I dont find it annoying
  2155. |> >very often. But I do have one complaint about it:
  2156. |> I think many of the things that you might just consider annoying,
  2157. |> I consider bugs.  A design flaw is a bug.
  2158.  
  2159. Perhaps so.
  2160.  
  2161. |>   I think you also have more patience with Apple than I do...
  2162. |>   But then, how many years is it *supposed* to take until you can
  2163. |> play sounds without crashing, hanging, or silencing the speaker?
  2164. |> It's been 8...
  2165.  
  2166. Rrrrgh! Dont remind me.. I had to shelve a good project (it played
  2167. sounds in the background) cuz I could not get the sound manager to
  2168. behave.
  2169.  
  2170. I DO consider this a bug.
  2171.  
  2172. |> >|> I recall that when I tried to use the Palette Wrecker (so long ago) to
  2173. |> >|> do stuff, it did not, in fact, like being used to take over very much
  2174. |> >|> of the CLUT.  Everything would be fine until a dialog or something
  2175. |> >|> came up, and then my nice green would suddenly be replaced by an icky
  2176. |> >|> brown (which the dialog didn't even use!)  Of course, this happens with
  2177. |> >|> CLUT setting too, but hey, the Palette Wrecker is supposed to fix such
  2178. |> >|> problems.
  2179. |> >I have never seen this, but it soudns like a bug. I have only
  2180. |> >written 1 prog that takes over the whole palette (less black and white),
  2181. |> >and it has a dialog box (and about box) and it does not have this
  2182. |> >problem.
  2183. |>   I'm quite certain of this.  Just set the CLUT to, say, a ramp from
  2184. |> white to black, and then bring up some dialogs and stuff.  This is
  2185. |> System 6 & 7.  It will shove nasty colors in there and not take them
  2186. |> out.  Very annoying.  At least, it does it on my machine :->
  2187.  
  2188. But it doesn't do it on mine. Then again, I set the palette not the CLUT,
  2189. so maybe that clues it in. Or maybe not. It still has never happened to
  2190. me, and I have tried to use dialogs with the entire palette allocated.
  2191.  
  2192. [deletia- code to refresh whole screen. go read it yerself. :) ]
  2193.  
  2194. Thanks!
  2195.  
  2196. [deletia- about getting the palette manager not to touch certain depths]
  2197.  
  2198. |> >I now agree that SetEntries is better if u r taking over the whole
  2199. |> >screen. It is also the ONLY way to get teh whole palette to yourself.
  2200. |> >The Palette Manager will NOT touch white or black, EVER.
  2201.  
  2202. [deletia- about not touching b&w]
  2203.  
  2204. |>   Amusing fact: you, and so many others, dread going as low-level as
  2205. |> SetEntries.
  2206.  
  2207. Oh, thats a little strong. I prefer not to go so low.. makes my life
  2208. more difficult that it has to be.. but I am not exactly cowering in the
  2209. closet afraid my Mac will come and get me if I dare to violate the
  2210. CLUT. :)
  2211.  
  2212. |>  Me, I've had to resort to calling the video driver
  2213. |> directly, because I considered SetEntries too slow...  And recently
  2214. |> I've been wondering if there isn't a way to get even lower-level -
  2215. |> some of those video drivers are pretty badly written, if you want to
  2216. |> get 60-75 CLUT switches a second...
  2217.  
  2218. Well, this probably would send me scrabling for my closet. :)
  2219.  
  2220. |>  So, pretty much the end of this thread, I think...
  2221.  
  2222. That may be. Im not placing any bets yet.
  2223. - -- 
  2224. copying            - Dan Johnson
  2225. And God said "Jeeze, this is dull"... and it *WAS* dull. Genesis 0:0
  2226.  
  2227. These opinions have had all identifiying marks removed, and are untraceable.
  2228. You'll never know whose they are.
  2229.  
  2230. +++++++++++++++++++++++++++
  2231.  
  2232. From: timm@void.ncsa.uiuc.edu (Tim McClarren)
  2233. Organization: University of Illinois at Urbana
  2234. Date: Fri, 11 Sep 1992 02:35:57 GMT
  2235.  
  2236. deadman@garnet.berkeley.edu (Ben Haller) writes:
  2237.  
  2238. >> - efficient collision detection algorithms
  2239. >  My current favorite is, keep a sorted list of sprites (keeping it
  2240. >sorted, assuming your sprites don't constantly teleport, is O(n)) and
  2241. >compare nearby elements in the sorted list (again, O(n) for normal cases).
  2242. >If you get a bounding box intersection, do a mask compare.  This is
  2243. >pretty efficient, I think.  I hope...
  2244.  
  2245. This seems to be the de-facto way of doing it.  I'd love to hear
  2246. from someone who hasn't used this method.  Is there another method?
  2247. What about geometric approaches?  Break the list in two, break those
  2248. lists in two, etc.  But now you've got to keep track of when it's
  2249. time for objects to jump lists.  I think the boundaries become
  2250. problematic in those cases, no?  Or how about breaking the universe
  2251. into radial areas?  Or does that involve too much expensive trigonometry?
  2252. And the center gets really nasty.  Also, what about "walls" or other
  2253. non-moving obstacles?  For the case of walls, does one simply break them
  2254. up into rectangles?  Is that the best?
  2255.  
  2256. What about hashing?  Can that be done?  Hash on some absolute location
  2257. every time through the loop for each object, and just compare those
  2258. objects that hash to the same place.  It seems like this could be
  2259. really fast (O(n)) and easy to implement.  And you don't have to worry
  2260. about those damned sorted lists :o).
  2261. - -- 
  2262. Tim McClarren     | "...a bajillion brilliant Jobsian lithium licks."
  2263. timm@ncsa.uiuc.edu|
  2264. (217)244-0015     |
  2265.  
  2266. +++++++++++++++++++++++++++
  2267.  
  2268. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  2269. Date: 12 Sep 92 06:40:49 GMT
  2270. Organization: University of Waikato, Hamilton, New Zealand
  2271.  
  2272. In article <18one7INNm74@agate.berkeley.edu>, deadman@garnet.berkeley.edu (Ben Haller) writes:
  2273. > In article <ah5ywvd@rpi.edu> johnsd2@rpi.edu writes:
  2274. >>|> I recall that when I tried to use the Palette Wrecker (so long ago) to
  2275. >>|> do stuff, it did not, in fact, like being used to take over very much
  2276. >>|> of the CLUT.  Everything would be fine until a dialog or something
  2277. >>|> came up, and then my nice green would suddenly be replaced by an icky
  2278. >>|> brown (which the dialog didn't even use!)  Of course, this happens with
  2279. >>|> CLUT setting too, but hey, the Palette Wrecker is supposed to fix such
  2280. >>|> problems.
  2281. >>I have never seen this, but it soudns like a bug. I have only
  2282. >>written 1 prog that takes over the whole palette (less black and white),
  2283. >>and it has a dialog box (and about box) and it does not have this
  2284. >>problem.
  2285. >   I'm quite certain of this.  Just set the CLUT to, say, a ramp from
  2286. > white to black, and then bring up some dialogs and stuff.  This is
  2287. > System 6 & 7.  It will shove nasty colors in there and not take them
  2288. > out.  Very annoying.  At least, it does it on my machine :->
  2289.  
  2290. Short of using the  pmExplicit flag, the Palette Manager only guarantees to
  2291. make available certain *sets* of colours--nowhere does it say that it will
  2292. make them available at particular locations in the colour table, or in a
  2293. particular order. If it doesn't take out those colours, it's because the
  2294. window you are switching to finds them acceptable. It may not return to
  2295. exactly the same CLUT configuration that you saw the previous time that same
  2296. window was frontmost, but that's because the Palette Manager does the minimum
  2297. amount of rearranging necessary each time.
  2298.  
  2299. > void InvalScreen()
  2300. > {
  2301. >     DrawMenuBar();
  2302. >     PaintOne(0L,GrayRgn);
  2303. >     PaintBehind(WindowList,GrayRgn);
  2304. > }
  2305.  
  2306. The PaintOne call is redundant; PaintBehind does it all. Also, why refer
  2307. to the WindowList when you can use FrontWindow?
  2308.  
  2309. Also, there's a problem with this code: Contrary to what IM1 may lead you to
  2310. believe, PaintBehind does not preserve the current GrafPort (don't know if
  2311. this is fixed in System 7).
  2312.  
  2313. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  2314. Computer Services Dept                     fax: +64-7-838-4066
  2315. University of Waikato            electric mail: ldo@waikato.ac.nz
  2316. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  2317. I'm not fond of benchmarks. I prefer my schmarks to be straight.
  2318.  
  2319. +++++++++++++++++++++++++++
  2320.  
  2321. From: bwilliam@iat.holonet.net (Bill Williams)
  2322. Organization: HoloNet (BBS: 510-704-1058)
  2323. Date: Fri, 11 Sep 1992 07:01:44 GMT
  2324.  
  2325. >As for mouse-positioning, I don't like relative either,
  2326. but I must say, I would probably ... too easy.
  2327.  
  2328.  
  2329. I think that crippling an interface to add challenge to be ghastly! Its
  2330. what turns "Vette" into a piece of crap with 9 position steering only and
  2331. no proportional positioning.
  2332.  
  2333. If you add proportional positioning to a game such as Solarian II which
  2334. lacks it and (I feel) suffers from it, then you can add more attackers and
  2335. more things to do to add "challenge"
  2336.  
  2337. an arcade interface should never appear crippled, erratic, choppy, or
  2338. delayed. An arcade interface SHOULD ALWAYS BE FAST AND PROPORTIONALLY
  2339. POSITIONAL. Even most of the Apple II games I had since 1979 were
  2340. not 8-way Atari-style joystick activated... well at least not the ones I
  2341. liked.
  2342.  
  2343. Ask anyone who doesn't like Solarian, not those that do enjoy it, what
  2344. they don't like and I'll bet a lot don't like the non-proportianal mouse
  2345. as being the only configuration allowed.
  2346.  
  2347. BWilliams
  2348.  
  2349.  
  2350. +++++++++++++++++++++++++++
  2351.  
  2352. From: timm@void.ncsa.uiuc.edu (Tim McClarren)
  2353. Organization: University of Illinois at Urbana
  2354. Date: Fri, 11 Sep 1992 08:10:10 GMT
  2355.  
  2356. bwilliam@iat.holonet.net (Bill Williams) writes:
  2357.  
  2358. >If you add proportional positioning to a game such as Solarian II which
  2359. >lacks it and (I feel) suffers from it, then you can add more attackers and
  2360. >more things to do to add "challenge"
  2361.  
  2362. Well, what's proportional positioning anyways?  I've not heard that
  2363. term used.  But, if you mean absolute positioning, then I disagree.
  2364. It's not as cut and dried as that.  If you change the positioning,
  2365. you affect the entire way in which the game as a whole works.  And
  2366. it may simply not be possible to add more attackers.  Maybe it just
  2367. bogs when you do...perhaps Ben can answer that.  Because you can't
  2368. learn the skill necessary to move the ship doesn't mean it's a bad
  2369. way to do positioning :o).
  2370.  
  2371. >an arcade interface should never appear crippled, erratic, choppy, or
  2372. >delayed. An arcade interface SHOULD ALWAYS BE FAST AND PROPORTIONALLY
  2373. >POSITIONAL. Even most of the Apple II games I had since 1979 were
  2374. >not 8-way Atari-style joystick activated... well at least not the ones I
  2375. >liked.
  2376.  
  2377. Hmm...this is strange.  Most of the people I talk to don't like
  2378. analog devices for positioning.  In fact, I can't think of a good
  2379. arcade game in recent memory that used an analog device.  Except
  2380. for maybe the games with steering wheels.  Actually, you're arguing
  2381. both ways, first you talk about arcade interfaces, which are generally
  2382. digital, and then you use the Apple II games as an example, which
  2383. were all analog...so which is it?  And anyways, who says an arcade
  2384. interface should always be fast and proportional?  Space Invaders and
  2385. PacMan (two of the most successful arcade games) both use relative
  2386. positioning.  The Atari's were all digital, Nintendo is digital.
  2387. It's impossible to absolute positioning on these (absolute in a fashion
  2388. that would allow for more than 8 or so locations).
  2389.  
  2390. Solarian doesn't really work in the same way as either of these,
  2391. but I would say that it somewhat resembles the way in which a digital
  2392. joystick works.  I think that's what Ben was aiming for.  Maybe
  2393. he can comment further.  But we're getting into c.s.m.g material
  2394. here and not c.s.m.p material.
  2395. - -- 
  2396. Tim McClarren     | "...a bajillion brilliant Jobsian lithium licks."
  2397. timm@ncsa.uiuc.edu|
  2398. (217)244-0015     |
  2399.  
  2400. +++++++++++++++++++++++++++
  2401.  
  2402. From: deadman@garnet.berkeley.edu (Ben Haller)
  2403. Date: 11 Sep 92 17:55:19 GMT
  2404. Organization: Stick Software
  2405.  
  2406. In article <1992Sep11.184049.10764@waikato.ac.nz> ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes:
  2407. >In article <18one7INNm74@agate.berkeley.edu>, deadman@garnet.berkeley.edu (Ben Haller) writes:
  2408. >> In article <ah5ywvd@rpi.edu> johnsd2@rpi.edu writes:
  2409. >> void InvalScreen()
  2410. >> {
  2411. >>     DrawMenuBar();
  2412. >>     PaintOne(0L,GrayRgn);
  2413. >>     PaintBehind(WindowList,GrayRgn);
  2414. >> }
  2415. >
  2416. >The PaintOne call is redundant; PaintBehind does it all. Also, why refer
  2417. >to the WindowList when you can use FrontWindow?
  2418.   The PaintOne call, if I recall correctly, repaints the desktop.  This
  2419. would not be done by the PaintBehind call, as far as I know.  IM I-297
  2420. says "PaintBehind calls PaintOne for startWindow and all the *windows*
  2421. behind startWindow..."  It does not paint the desktop, that needs to
  2422. be done explicitly (because the desktop has no update region, so calling
  2423. PaintBehind would just have to repaint the whole desktop every time, which
  2424. would be slow and lame).
  2425.   WindowList: hmm, hadn't thought about it.  Old code.  However, this is
  2426. at least *slightly* less likely to skip over a window, for example a
  2427. GhostWindow (yes, I know nobody uses those) or a window that has been
  2428. "removed" from the window list with a patch to FrontWindow, or something
  2429. like that.  Basically no reason, I suppose.
  2430.  
  2431. >Also, there's a problem with this code: Contrary to what IM1 may lead you to
  2432. >believe, PaintBehind does not preserve the current GrafPort (don't know if
  2433. >this is fixed in System 7).
  2434.   Yeah, I don't regard it as a problem because I call it in Solarian II
  2435. right before doing an ExitToShell, so...what do I care?  But for others,
  2436. that's a good point (if true, I don't know...)
  2437.  
  2438. - -Ben Haller (deadman@garnet.berkeley.edu)
  2439.  
  2440. +++++++++++++++++++++++++++
  2441.  
  2442. From: deadman@garnet.berkeley.edu (Ben Haller)
  2443. Date: 11 Sep 92 18:15:52 GMT
  2444. Organization: Stick Software
  2445.  
  2446.  
  2447.   Boy, this is a fun thread.
  2448.  
  2449. In article <timm.716178957@void> timm@void.ncsa.uiuc.edu (Tim McClarren) writes:
  2450. >deadman@garnet.berkeley.edu (Ben Haller) writes:
  2451. >>> - efficient collision detection algorithms
  2452. >>  My current favorite is, keep a sorted list of sprites (keeping it
  2453. >>sorted, assuming your sprites don't constantly teleport, is O(n)) and
  2454. >>compare nearby elements in the sorted list (again, O(n) for normal cases).
  2455. >>If you get a bounding box intersection, do a mask compare.  This is
  2456. >>pretty efficient, I think.  I hope...
  2457. >
  2458. >This seems to be the de-facto way of doing it.  I'd love to hear
  2459. >from someone who hasn't used this method.  Is there another method?
  2460. >What about geometric approaches?  Break the list in two, break those
  2461. >lists in two, etc.  But now you've got to keep track of when it's
  2462. >time for objects to jump lists.  I think the boundaries become
  2463. >problematic in those cases, no?  Or how about breaking the universe
  2464. >into radial areas?  Or does that involve too much expensive trigonometry?
  2465. >And the center gets really nasty.  Also, what about "walls" or other
  2466. >non-moving obstacles?  For the case of walls, does one simply break them
  2467. >up into rectangles?  Is that the best?
  2468.   Hmm.  Most of these ideas are not so hot, I think.  Why would you
  2469. *want* to break the list into parts?  Why would you *want* to use
  2470. radial areas (assuming your game isn't radially-based, like Tempest or
  2471. something)?
  2472.   Walls are generally a separate issue.  Depending on what kind of walls
  2473. you have, you might have an array representing where the walls are in
  2474. your world so you can do an array look-up to see if a particular area
  2475. contains a wall, or you might treat them as sprites and keep them in the
  2476. collision list (this would usually not be appropriate, however), or maybe
  2477. some other way...
  2478.   I think the sorted list approach makes a hell of a lot of sense, as
  2479. does your hash table idea.  I would also be interesting in hearing
  2480. alternatives.
  2481.   Of course, once you get a bounding box intersection (or a hash table
  2482. collision, as the case may be) you don't need to do a *mask* compare, you
  2483. could do a polygon-polygon intersection, or a circle-intersection test,
  2484. or various things like that...
  2485.  
  2486. >What about hashing?  Can that be done?  Hash on some absolute location
  2487. >every time through the loop for each object, and just compare those
  2488. >objects that hash to the same place.  It seems like this could be
  2489. >really fast (O(n)) and easy to implement.  And you don't have to worry
  2490. >about those damned sorted lists :o).
  2491.   Well, when I was typing up there it seemed like a good idea.  But now
  2492. it doesn't.  Why not?  Well imagine starting at x=10.  That hashes to a
  2493. particular value.  Now presumably you want nearby coordinates to hash to
  2494. the same value (so you do, in fact, detect a collision), so x=11 would
  2495. probably hash to the same value.  Continue upwards until your hash function
  2496. produces a different value, at say x=20.  Now.  Suppose you have a sprite
  2497. at x=19 and one at x=20.  Clearly they should collide, but they hash to
  2498. different values.  So how do you detect the collision?
  2499.   Also: what exactly are you hashing on?  The center of the sprite?  The
  2500. left edge?  What about sprites that are very wide, such that they collide
  2501. with objects that hash several places away?  Etc.
  2502.  
  2503. - -Ben Haller (deadman@garnet.berkeley.edu)
  2504.  
  2505. +++++++++++++++++++++++++++
  2506.  
  2507. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  2508. Date: 11 Sep 92 19:38:26 GMT
  2509. Organization: Kalamazoo College
  2510.  
  2511. deadman@garnet.berkeley.edu (Ben Haller) writes:
  2512. >  Boy, this is a fun thread.
  2513.  
  2514. Hope that wasn't sarcastic...
  2515.  
  2516. >  I think the sorted list approach makes a hell of a lot of sense, as
  2517. >does your hash table idea.  I would also be interesting in hearing
  2518. >alternatives.
  2519.  
  2520. For a physical simulation program a few years back, I had to detect
  2521. collisions with spheres very quickly.  I put together a lookup table in
  2522. which the spheres in a given square were stored in a linked list;  the
  2523. length of the edge of each square was equal to the radius of the sphere.
  2524. (Actually, it was in 3-space, and I ended up making the edge half again
  2525. as long for speed's sake, and the spheres' locations were
  2526. pseudo-randomly generated not stored in a table, but the principle's
  2527. the same.)
  2528.  
  2529. So, if you have an object whose center is 0,0, and the sum of its radius [*]
  2530. and the radius of the longest object in the game is x, you only have to
  2531. search the linked lists that contain the objects in the rectangle (-x,
  2532. - -x, x, x).  Obviously, the unit of measure should not be 1 pixel.  It
  2533. should be large enough that you don't waste too much time searching
  2534. empty lists and relocating objects from one list to the other.  And it
  2535. should be small enough that you don't waste too much time searching
  2536. overly long lists.
  2537.  
  2538. [*] Define radius however you want, of course.  It might be appropriate
  2539. to have an x and a y radius, so you'd search in the rect (-x, -y, x, y).
  2540. - -- 
  2541.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  2542.  So I'm rattling the bars around this drink-tank discreetly;  I should pour up
  2543.  through the keyhole or evaporate completely, but there'd be no percentage and
  2544.  there'd be no proof, and the sound upon the roof is only water...      - TMBG
  2545.  
  2546. +++++++++++++++++++++++++++
  2547.  
  2548. From: hd12@ellis.uchicago.edu (hui  dong)
  2549. Organization: University of Chicago Computing Organizations
  2550. Date: Sun, 13 Sep 1992 08:41:08 GMT
  2551.  
  2552. I am also very interested in creating fast animation. I wrote a test program
  2553. to draw directly to the screen, or draw to an off GWorld then CopyBits. But
  2554. here is my question: if I "draw" by directly change the pixel values, what is
  2555. the difference between using offGWorld and drawing directly to the screen?
  2556. CopyBits takes very little time, relatively. Is writing to GWorld as "dangerous"
  2557. as writing to the screen? (in fact, I open a window as current port, and take
  2558. it as "current" GWorld, writing to it is just like writing to a off GWorld.)
  2559.  
  2560. Also, although it's easy to create some fix pattern graphics by writing
  2561. to the memory, how can one plot, say, an icon (a man, a dog) by changing the
  2562. pixel values, and even do animation?
  2563.  
  2564.  
  2565.  
  2566. +++++++++++++++++++++++++++
  2567.  
  2568. From: hd12@ellis.uchicago.edu (hui  dong)
  2569. Organization: University of Chicago Computing Organizations
  2570. Date: Sun, 13 Sep 1992 08:43:43 GMT
  2571.  
  2572. I am also very interested in creating fast animation. I wrote a test program
  2573. to draw directly to the screen, or draw to an off GWorld then CopyBits. But
  2574. here is my question: if I "draw" by directly change the pixel values, what is
  2575. the difference between using offGWorld and drawing directly to the screen?
  2576. CopyBits takes very little time, relatively. Is writing to GWorld as "dangerous"
  2577. as writing to the screen? (in fact, I open a window as current port, and take
  2578. it as "current" GWorld, writing to it is just like writing to a off GWorld.)
  2579.  
  2580. Also, although it's easy to create some fix pattern graphics by writing
  2581. to the memory, how can one plot, say, an icon (a man, a dog) by changing the
  2582. pixel values, and even do animation?
  2583.  
  2584.  
  2585.  
  2586. +++++++++++++++++++++++++++
  2587.  
  2588. From: deadman@garnet.berkeley.edu (Ben Haller)
  2589. Date: 18 Sep 92 16:57:30 GMT
  2590. Organization: Stick Software
  2591.  
  2592. In article <1992Sep13.084343.7462@midway.uchicago.edu>
  2593.   hd12@midway.uchicago.edu writes:
  2594. >I am also very interested in creating fast animation. I wrote a test program
  2595. >to draw directly to the screen, or draw to an off GWorld then CopyBits. But
  2596. >here is my question: if I "draw" by directly change the pixel values, what is
  2597. >the difference between using offGWorld and drawing directly to the screen?
  2598. >CopyBits takes very little time, relatively. Is writing to GWorld as
  2599. >"dangerous" as writing to the screen? (in fact, I open a window as current
  2600. >port, and take it as "current" GWorld, writing to it is just like writing
  2601. >to a off GWorld.)
  2602.   The key phrase here is "CopyBits takes very little time, relatively."  If
  2603. you don't mind the overhead of CopyBits, then yes, feel free to use an
  2604. offscreen GWorld, that's very nice.  But if you want "fast animation",
  2605. as you say, the overhead of CopyBits is unacceptable.
  2606.   I have no idea if writing to GWorlds is similar to drawing direct to
  2607. screen, what the relative danger level is, etc., since I have never
  2608. done it.  Sorry.
  2609.  
  2610. >Also, although it's easy to create some fix pattern graphics by writing
  2611. >to the memory, how can one plot, say, an icon (a man, a dog) by changing the
  2612. >pixel values, and even do animation?
  2613.   The principle is the same - just write different color values to the
  2614. different pixels, and you're done.
  2615.   In practice, it is (usually) easier to have an offscreen copy of the
  2616. image, and move that image to the screen by reading bytes (or preferably
  2617. longwords for speed) and writing them out to the proper place in screen
  2618. memory.
  2619.   In certain cases it is even better to just write the values using
  2620. a hard-coded routine that can only "stamp" the one image it has been
  2621. written to produce, thus saving the reads from memory for the image.
  2622.   To do animation, just display several images in quick succession, making
  2623. sure that you remove the traces of each previous image as you display each
  2624. next image...
  2625.  
  2626. - -Ben Haller (deadman@garnet.berkeley.edu)
  2627.  
  2628. ---------------------------
  2629.  
  2630. End of C.S.M.P. Digest
  2631. **********************
  2632.